Closed goliatone closed 5 years ago
Currently if we have a function as an attribute of one of the objects to be overwriting we end up extending the function instead of replacing it.
const defaults = { //We want to shim console logger: _=> console }; const config = { logger: {level: 'info', log(){}...} }; let info = extend({}, defaults, config); typeof info.logger === 'function' typeof info.logger.level === 'string'
Make sure we compare to funct:
if (source[property] && source[property].constructor && source[property].constructor === Object) { target[property] = target[property] || {}; if (typeof target[property] === 'function') target[property] = source[property];//<<< ADD else target[property] = extend(target[property], source[property]); } else target[property] = source[property];
Currently if we have a function as an attribute of one of the objects to be overwriting we end up extending the function instead of replacing it.
Make sure we compare to funct: