[d24f17c] | 1 | var _curry2 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry2.js");
|
---|
| 4 |
|
---|
| 5 | var map =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./map.js");
|
---|
| 8 |
|
---|
| 9 | var prop =
|
---|
| 10 | /*#__PURE__*/
|
---|
| 11 | require("./prop.js");
|
---|
| 12 | /**
|
---|
| 13 | * Returns a new list by plucking the same named property off all objects in
|
---|
| 14 | * the list supplied.
|
---|
| 15 | *
|
---|
| 16 | * `pluck` will work on
|
---|
| 17 | * any [functor](https://github.com/fantasyland/fantasy-land#functor) in
|
---|
| 18 | * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`.
|
---|
| 19 | *
|
---|
| 20 | * @func
|
---|
| 21 | * @memberOf R
|
---|
| 22 | * @since v0.1.0
|
---|
| 23 | * @category List
|
---|
| 24 | * @sig Functor f => k -> f {k: v} -> f v
|
---|
| 25 | * @param {Number|String} key The key name to pluck off of each object.
|
---|
| 26 | * @param {Array} f The array or functor to consider.
|
---|
| 27 | * @return {Array} The list of values for the given key.
|
---|
| 28 | * @see R.project, R.prop, R.props
|
---|
| 29 | * @example
|
---|
| 30 | *
|
---|
| 31 | * var getAges = R.pluck('age');
|
---|
| 32 | * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27]
|
---|
| 33 | *
|
---|
| 34 | * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3]
|
---|
| 35 | * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5}
|
---|
| 36 | * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5]
|
---|
| 37 | * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5]
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | var pluck =
|
---|
| 42 | /*#__PURE__*/
|
---|
| 43 | _curry2(function pluck(p, list) {
|
---|
| 44 | return map(prop(p), list);
|
---|
| 45 | });
|
---|
| 46 |
|
---|
| 47 | module.exports = pluck; |
---|