source: imaps-frontend/node_modules/lodash-es/pullAt.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import arrayMap from './_arrayMap.js';
2import baseAt from './_baseAt.js';
3import basePullAt from './_basePullAt.js';
4import compareAscending from './_compareAscending.js';
5import flatRest from './_flatRest.js';
6import isIndex from './_isIndex.js';
7
8/**
9 * Removes elements from `array` corresponding to `indexes` and returns an
10 * array of removed elements.
11 *
12 * **Note:** Unlike `_.at`, this method mutates `array`.
13 *
14 * @static
15 * @memberOf _
16 * @since 3.0.0
17 * @category Array
18 * @param {Array} array The array to modify.
19 * @param {...(number|number[])} [indexes] The indexes of elements to remove.
20 * @returns {Array} Returns the new array of removed elements.
21 * @example
22 *
23 * var array = ['a', 'b', 'c', 'd'];
24 * var pulled = _.pullAt(array, [1, 3]);
25 *
26 * console.log(array);
27 * // => ['a', 'c']
28 *
29 * console.log(pulled);
30 * // => ['b', 'd']
31 */
32var pullAt = flatRest(function(array, indexes) {
33 var length = array == null ? 0 : array.length,
34 result = baseAt(array, indexes);
35
36 basePullAt(array, arrayMap(indexes, function(index) {
37 return isIndex(index, length) ? +index : index;
38 }).sort(compareAscending));
39
40 return result;
41});
42
43export default pullAt;
Note: See TracBrowser for help on using the repository browser.