AK-21/Graphite-Industrial-Intelligence
0
1'use strict';2 3function mergeDescriptors(destination, source, overwrite = true) {4 if (!destination) {5 throw new TypeError('The `destination` argument is required.');6 }7 8 if (!source) {9 throw new TypeError('The `source` argument is required.');10 }11 12 for (const name of Object.getOwnPropertyNames(source)) {13 if (!overwrite && Object.hasOwn(destination, name)) {14 // Skip descriptor15 continue;16 }17 18 // Copy descriptor19 const descriptor = Object.getOwnPropertyDescriptor(source, name);20 Object.defineProperty(destination, name, descriptor);21 }22 23 return destination;24}25 26module.exports = mergeDescriptors;27 