206b1965f5703492aedfbabee31fcd77b564f5af
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / _basePullAt.js
1 var baseToPath = require('./_baseToPath'),
2     isIndex = require('./_isIndex'),
3     isKey = require('./_isKey'),
4     last = require('./last'),
5     parent = require('./_parent');
6
7 /** Used for built-in method references. */
8 var arrayProto = Array.prototype;
9
10 /** Built-in value references. */
11 var splice = arrayProto.splice;
12
13 /**
14  * The base implementation of `_.pullAt` without support for individual
15  * indexes or capturing the removed elements.
16  *
17  * @private
18  * @param {Array} array The array to modify.
19  * @param {number[]} indexes The indexes of elements to remove.
20  * @returns {Array} Returns `array`.
21  */
22 function basePullAt(array, indexes) {
23   var length = array ? indexes.length : 0,
24       lastIndex = length - 1;
25
26   while (length--) {
27     var index = indexes[length];
28     if (lastIndex == length || index != previous) {
29       var previous = index;
30       if (isIndex(index)) {
31         splice.call(array, index, 1);
32       }
33       else if (!isKey(index, array)) {
34         var path = baseToPath(index),
35             object = parent(array, path);
36
37         if (object != null) {
38           delete object[last(path)];
39         }
40       }
41       else {
42         delete array[index];
43       }
44     }
45   }
46   return array;
47 }
48
49 module.exports = basePullAt;