| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1 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
* @version 0.1.0 (2011/01/12)
*/
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;
});
|