UNPKG

@mightyplow/jslib

Version:

js helpers library

22 lines (19 loc) 528 B
/** * Creates a function which extracts some properties out of an object. * * @memberOf object * @param {string[]} props * @return {Function} */ var extract = function extract() { for (var _len = arguments.length, props = Array(_len), _key = 0; _key < _len; _key++) { props[_key] = arguments[_key]; } return function (obj) { return props.reduce(function (extracted, key) { extracted[key] = obj[key]; return extracted; }, {}); }; }; export default extract;