Code coverage report for array/intersection.js

Statements: 100% (8 / 8)      Branches: 100% (0 / 0)      Functions: 100% (5 / 5)      Lines: 100% (7 / 7)     

All files » array/ » intersection.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211             1 3   7 10     3     1      
define(['./unique', './filter', './every', './contains'], function (unique, filter, every, contains) {
 
 
    /**
     * Return a new Array with elements common to all Arrays.
     * - based on underscore.js implementation
     */
    function intersection(arr) {
        var arrs = Array.prototype.slice.call(arguments, 1),
            result = filter(unique(arr), function(needle){
                return every(arrs, function(haystack){
                    return contains(haystack, needle);
                });
            });
        return result;
    }
 
    return intersection;
 
});