difference.js 515 B

12345678910111213141516
  1. var restArguments = require('./restArguments.js');
  2. var _flatten = require('./_flatten.js');
  3. var filter = require('./filter.js');
  4. var contains = require('./contains.js');
  5. // Take the difference between one array and a number of other arrays.
  6. // Only the elements present in just the first array will remain.
  7. var difference = restArguments(function(array, rest) {
  8. rest = _flatten(rest, true, true);
  9. return filter(array, function(value){
  10. return !contains(rest, value);
  11. });
  12. });
  13. module.exports = difference;