UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

27 lines (25 loc) 712 B
/** * Populates an object with properties of another object * @param {Object} source Source object * @param {string[]} properties Properties names to include * @returns object populated with the picked keys */ const pick = function (source) { let keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; return keys.reduce((o, key) => { if (key in source) { o[key] = source[key]; } return o; }, {}); }; const pickBy = (source, predicate) => { return Object.keys(source).reduce((o, key) => { if (predicate(source[key], key, source)) { o[key] = source[key]; } return o; }, {}); }; export { pick, pickBy }; //# sourceMappingURL=pick.mjs.map