type-fns
Version:
A set of types, type checks, and type guards for simpler, safer, and easier to read code.
15 lines • 555 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.pick = void 0;
/**
* a companion to the `Pick` type, returns a new object with only the picked attributes
*/
const pick = (obj, keys) => Object.entries(obj).reduce((summary, [key, value]) => {
// if key is not in the specified keys, dont add it to the new object
if (!keys.includes(key))
return summary;
// if it is within specified keys, add it
return { ...summary, [key]: value };
}, {});
exports.pick = pick;
//# sourceMappingURL=pick.js.map