You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
922 B

4 years ago
  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. * @example
  18. *
  19. * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2};
  20. * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7};
  21. * const kids = [abby, fred];
  22. * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]
  23. */
  24. var project =
  25. /*#__PURE__*/
  26. useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity
  27. export default project;