5863749382f27aad92ba01fdfe7391f95d22557f
[platform/framework/web/crosswalk-tizen.git] /
1 var append = require('./append');
2 var makeIterator = require('../function/makeIterator_');
3
4     /**
5      * Maps the items in the array and concatenates the result arrays.
6      */
7     function collect(arr, callback, thisObj){
8         callback = makeIterator(callback, thisObj);
9         var results = [];
10         if (arr == null) {
11             return results;
12         }
13
14         var i = -1, len = arr.length;
15         while (++i < len) {
16             var value = callback(arr[i], i, arr);
17             if (value != null) {
18                 append(results, value);
19             }
20         }
21
22         return results;
23     }
24
25     module.exports = collect;
26
27