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:
833 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import { curry, ap, path, __ } from 'ramda';
|
---|
| 2 |
|
---|
| 3 | /**
|
---|
| 4 | * Acts as multiple path: arrays of paths in, array of values out. Preserves order.
|
---|
| 5 | *
|
---|
| 6 | * @func paths
|
---|
| 7 | * @memberOf RA
|
---|
| 8 | * @since {@link https://char0n.github.io/ramda-adjunct/1.2.0|v1.2.0}
|
---|
| 9 | * @category List
|
---|
| 10 | * @sig [[k]] -> {k: v} - [v]
|
---|
| 11 | * @param {Array} ps The property paths to fetch
|
---|
| 12 | * @param {Object} obj The object to query
|
---|
| 13 | * @return {Array} The corresponding values or partially applied function
|
---|
| 14 | * @see {@link https://github.com/ramda/ramda/wiki/Cookbook#derivative-of-rprops-for-deep-fields|Ramda Cookbook}, {@link http://ramdajs.com/docs/#props|R.props}
|
---|
| 15 | * @example
|
---|
| 16 | *
|
---|
| 17 | * const obj = {
|
---|
| 18 | * a: { b: { c: 1 } },
|
---|
| 19 | * x: 2,
|
---|
| 20 | * };
|
---|
| 21 | *
|
---|
| 22 | * RA.paths([['a', 'b', 'c'], ['x']], obj); //=> [1, 2]
|
---|
| 23 | */
|
---|
| 24 | const paths = curry((ps, obj) => ap([path(__, obj)], ps));
|
---|
| 25 |
|
---|
| 26 | export default paths;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.