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.

31 lines
893 B

4 years ago
  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. * @example
  16. *
  17. * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
  18. * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2]
  19. *
  20. * const fullName = R.compose(R.join(' '), R.props(['first', 'last']));
  21. * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth'
  22. */
  23. var props =
  24. /*#__PURE__*/
  25. _curry2(function props(ps, obj) {
  26. return ps.map(function (p) {
  27. return path([p], obj);
  28. });
  29. });
  30. export default props;