Skip to main content
Module

x/ramda/props.js

:ram: Practical functional Javascript
Very Popular
Go to Latest
File
import _curry2 from './internal/_curry2';

/** * Acts as multiple `prop`: array of keys in, array of values out. Preserves * order. * * @func * @memberOf R * @since v0.1.0 * @category Object * @sig [k] -> {k: v} -> [v] * @param {Array} ps The property names to fetch * @param {Object} obj The object to query * @return {Array} The corresponding values or partially applied function. * @example * * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2] * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2] * * const fullName = R.compose(R.join(' '), R.props(['first', 'last'])); * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth' */var props = _curry2(function props(ps, obj) { var len = ps.length; var out = []; var idx = 0;
while (idx < len) { out[idx] = obj[ps[idx]]; idx += 1; }
return out;});export default props;