removeAll.js 331 B

123456789101112131415
  1. var indexOf = require('./indexOf');
  2. /**
  3. * Remove all instances of an item from array.
  4. */
  5. function removeAll(arr, item){
  6. var idx = indexOf(arr, item);
  7. while (idx !== -1) {
  8. arr.splice(idx, 1);
  9. idx = indexOf(arr, item, idx);
  10. }
  11. }
  12. module.exports = removeAll;