difference.js
608 Bytes
var unique = require('./unique');
var filter = require('./filter');
var some = require('./some');
var contains = require('./contains');
var slice = require('./slice');
/**
* Return a new Array with elements that aren't present in the other Arrays.
*/
function difference(arr) {
var arrs = slice(arguments, 1),
result = filter(unique(arr), function(needle){
return !some(arrs, function(haystack){
return contains(haystack, needle);
});
});
return result;
}
module.exports = difference;