source: node_modules/ramda-adjunct/src/omitIndexes.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 901 bytes
Line 
1import { includes, curry, addIndex, reject } from 'ramda';
2
3// helpers
4const rejectIndexed = addIndex(reject);
5const containsIndex = curry((indexes, val, index) => includes(index, indexes));
6
7/**
8 * Returns a partial copy of an array omitting the indexes specified.
9 *
10 * @func omitIndexes
11 * @memberOf RA
12 * @since {@link https://char0n.github.io/ramda-adjunct/1.19.0|v1.19.0}
13 * @category List
14 * @sig [Int] -> [a] -> [a]
15 * @see {@link http://ramdajs.com/docs/#omit|R.omit}, {@link RA.pickIndexes|pickIndexes}
16 * @param {!Array} indexes The array of indexes to omit from the new array
17 * @param {!Array} list The array to copy from
18 * @return {!Array} The new array with omitted indexes
19 * @example
20 *
21 * RA.omitIndexes([-1, 1, 3], ['a', 'b', 'c', 'd']); //=> ['a', 'c']
22 */
23const omitIndexes = curry((indexes, list) =>
24 rejectIndexed(containsIndex(indexes), list)
25);
26
27export default omitIndexes;
Note: See TracBrowser for help on using the repository browser.