copy-constructor-properties.js 705 B

12345678910111213141516
  1. var hasOwn = require('../internals/has-own-property');
  2. var ownKeys = require('../internals/own-keys');
  3. var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
  4. var definePropertyModule = require('../internals/object-define-property');
  5. module.exports = function (target, source, exceptions) {
  6. var keys = ownKeys(source);
  7. var defineProperty = definePropertyModule.f;
  8. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  9. for (var i = 0; i < keys.length; i++) {
  10. var key = keys[i];
  11. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  12. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  13. }
  14. }
  15. };