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:
955 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _map from "./internal/_map.js";
|
---|
| 2 | import identity from "./identity.js";
|
---|
| 3 | import pickAll from "./pickAll.js";
|
---|
| 4 | import useWith from "./useWith.js";
|
---|
| 5 | /**
|
---|
| 6 | * Reasonable analog to SQL `select` statement.
|
---|
| 7 | *
|
---|
| 8 | * @func
|
---|
| 9 | * @memberOf R
|
---|
| 10 | * @since v0.1.0
|
---|
| 11 | * @category Object
|
---|
| 12 | * @category Relation
|
---|
| 13 | * @sig [k] -> [{k: v}] -> [{k: v}]
|
---|
| 14 | * @param {Array} props The property names to project
|
---|
| 15 | * @param {Array} objs The objects to query
|
---|
| 16 | * @return {Array} An array of objects with just the `props` properties.
|
---|
| 17 | * @see R.pluck, R.props, R.prop
|
---|
| 18 | * @example
|
---|
| 19 | *
|
---|
| 20 | * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2};
|
---|
| 21 | * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7};
|
---|
| 22 | * const kids = [abby, fred];
|
---|
| 23 | * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | var project =
|
---|
| 27 | /*#__PURE__*/
|
---|
| 28 | useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity
|
---|
| 29 |
|
---|
| 30 | export default project; |
---|
Note:
See
TracBrowser
for help on using the repository browser.