merge-extends.js
walk the extend(s) property of an object, returning a single merged object
Usage
; const objects = ; const getter = objects; // you can just pass an identifier if you likeobjects;; // { abc: 123 } // or you can pass a whole source objectobjects;; // { def: 456, lmn: 345 } // you can conveniently use the same getter over and overconst objectsMerger = ;objects;; // { def: 456, ghi: 789 } // we also support an array of extendsobjects;; // { abc: 123, def: 456, ghi: 789, jki: 1012 } // an optional customiser can be used to implement deep mergingconst concatArrays = { return Array ? targetValue : sourceValue;};const customObjectsMerger = ;objects;objects;objects;; // { names: [ 'canary', 'sardine' ] }
API
mergeExtends(source, getter, customiser)
- @param {Object|String} source
- @param {Function} getter
- @param {Function} [customiser]
- @returns {Object}
Like lodash.assign(),
we invoke the optional customiser
function with five arguments:
(targetValue, sourceValue, key, target, source).
merger(getter, customiser)
- @param {Function} getter
- @param {Function} [customiser]
- @returns {Function}