doff
Version:
A powerful tool to free your objects and arrays from unwanted content
18 lines (12 loc) • 381 B
JavaScript
;
// Load modules
const arrayEach = require('./arrayEach');
const bind = require('./bind');
// Define exports
module.exports = function extend(target, source, context) {
arrayEach(Reflect.ownKeys(source), (key) => {
const value = source[key];
target[key] = context && typeof value === 'function' ? bind(value, context) : value;
});
return target;
};