source: node_modules/ramda-adjunct/es/omitIndexes.js

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

Initial commit

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