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:
928 bytes
|
Line | |
---|
1 | import _curry2 from "./internal/_curry2.js";
|
---|
2 | import path from "./path.js";
|
---|
3 | /**
|
---|
4 | * Acts as multiple `prop`: array of keys in, array of values out. Preserves
|
---|
5 | * order.
|
---|
6 | *
|
---|
7 | * @func
|
---|
8 | * @memberOf R
|
---|
9 | * @since v0.1.0
|
---|
10 | * @category Object
|
---|
11 | * @sig [k] -> {k: v} -> [v]
|
---|
12 | * @param {Array} ps The property names to fetch
|
---|
13 | * @param {Object} obj The object to query
|
---|
14 | * @return {Array} The corresponding values or partially applied function.
|
---|
15 | * @see R.prop, R.pluck, R.project
|
---|
16 | * @example
|
---|
17 | *
|
---|
18 | * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
|
---|
19 | * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2]
|
---|
20 | *
|
---|
21 | * const fullName = R.compose(R.join(' '), R.props(['first', 'last']));
|
---|
22 | * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth'
|
---|
23 | */
|
---|
24 |
|
---|
25 | var props =
|
---|
26 | /*#__PURE__*/
|
---|
27 | _curry2(function props(ps, obj) {
|
---|
28 | return ps.map(function (p) {
|
---|
29 | return path([p], obj);
|
---|
30 | });
|
---|
31 | });
|
---|
32 |
|
---|
33 | export default props; |
---|
Note:
See
TracBrowser
for help on using the repository browser.