UNPKG

925 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4
5var path =
6/*#__PURE__*/
7require("./path");
8/**
9 * Acts as multiple `prop`: array of keys in, array of values out. Preserves
10 * order.
11 *
12 * @func
13 * @memberOf R
14 * @since v0.1.0
15 * @category Object
16 * @sig [k] -> {k: v} -> [v]
17 * @param {Array} ps The property names to fetch
18 * @param {Object} obj The object to query
19 * @return {Array} The corresponding values or partially applied function.
20 * @example
21 *
22 * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
23 * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2]
24 *
25 * const fullName = R.compose(R.join(' '), R.props(['first', 'last']));
26 * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth'
27 */
28
29
30var props =
31/*#__PURE__*/
32_curry2(function props(ps, obj) {
33 return ps.map(function (p) {
34 return path([p], obj);
35 });
36});
37
38module.exports = props;
\No newline at end of file