Update JSON API
[src/app-framework-demo.git] / afm-client / bower_components / jszip / documentation / api_jszip / filter.md
1 ---
2 title: "filter(predicate)"
3 layout: default
4 section: api
5 ---
6
7 __Description__ : Filter nested files/folders with the specified function.
8
9 __Arguments__
10
11 name      | type     | description
12 ----------|----------|------------
13 predicate | function | the predicate to use.
14
15 The predicate has the following signature : `function (relativePath, file) {...}` :
16
17 name         | type      | description
18 -------------|-----------|------------
19 relativePath | string    | the filename and its path, reliatively to the current folder.
20 file         | ZipObject | the file being tested. See [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html).
21
22 The predicate must return true if the file should be included, false otherwise.
23
24
25 __Returns__ : An array of matching ZipObject.
26
27 __Throws__ : Nothing.
28
29 <!-- __Complexity__ : **O(k)** where k is the number of entries. -->
30
31 __Example__
32
33 ```js
34 var zip = new JSZip().folder("dir");
35 zip.file("readme.txt", "content");
36 zip.filter(function (relativePath, file){
37   // relativePath == "readme.txt"
38   // file = {name:"dir/readme.txt",options:{...},asText:function}
39   return true/false;
40 });
41 ```
42
43