source: node_modules/ramda-adjunct/lib/pickIndexes.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: 1.1 KB
RevLine 
[d24f17c]1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6// helpers
7var filterIndexed = (0, _ramda.addIndex)(_ramda.filter);
8var containsIndex = (0, _ramda.curry)(function (indexes, val, index) {
9 return (0, _ramda.includes)(index, indexes);
10});
11
12/**
13 * Picks values from list by indexes.
14 *
15 * Note: pickIndexes will skip non existing indexes. If you want to include them
16 * use ramda's `props` function.
17 *
18 * @func pickIndexes
19 * @memberOf RA
20 * @since {@link https://char0n.github.io/ramda-adjunct/1.1.0|v1.1.0}
21 * @category List
22 * @sig [Number] -> [a] -> [a]
23 * @param {Array} indexes The indexes to pick
24 * @param {Array} list The list to pick values from
25 * @return {Array} New array containing only values at `indexes`
26 * @see {@link http://ramdajs.com/docs/#pick|R.pick}, {@link RA.omitIndexes|omitIndexes}
27 * @example
28 *
29 * RA.pickIndexes([0, 2], ['a', 'b', 'c']); //=> ['a', 'c']
30 */
31var pickIndexes = (0, _ramda.curry)(function (indexes, list) {
32 return filterIndexed(containsIndex(indexes), list);
33});
34var _default = pickIndexes;
35exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.