3 * Copyright(c) 2014 Jonathan Ong
4 * Copyright(c) 2015 Douglas Christopher Wilson
15 module.exports = merge
22 var hasOwnProperty = Object.prototype.hasOwnProperty
25 * Merge the property descriptors of `src` into `dest`
27 * @param {object} dest Object to add descriptors to
28 * @param {object} src Object to clone descriptors from
29 * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
30 * @returns {object} Reference to dest
34 function merge(dest, src, redefine) {
36 throw new TypeError('argument dest is required')
40 throw new TypeError('argument src is required')
43 if (redefine === undefined) {
48 Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {
49 if (!redefine && hasOwnProperty.call(dest, name)) {
55 var descriptor = Object.getOwnPropertyDescriptor(src, name)
56 Object.defineProperty(dest, name, descriptor)