basePullAt.js 780 B

123456789101112131415161718192021222324252627282930
  1. var isIndex = require('./isIndex');
  2. /** Used for native method references. */
  3. var arrayProto = Array.prototype;
  4. /** Native method references. */
  5. var splice = arrayProto.splice;
  6. /**
  7. * The base implementation of `_.pullAt` without support for individual
  8. * index arguments and capturing the removed elements.
  9. *
  10. * @private
  11. * @param {Array} array The array to modify.
  12. * @param {number[]} indexes The indexes of elements to remove.
  13. * @returns {Array} Returns `array`.
  14. */
  15. function basePullAt(array, indexes) {
  16. var length = array ? indexes.length : 0;
  17. while (length--) {
  18. var index = indexes[length];
  19. if (index != previous && isIndex(index)) {
  20. var previous = index;
  21. splice.call(array, index, 1);
  22. }
  23. }
  24. return array;
  25. }
  26. module.exports = basePullAt;