defaults.js 367 B

1234567891011
  1. export default function _defaults(obj, defaults) {
  2. var keys = Object.getOwnPropertyNames(defaults);
  3. for (var i = 0; i < keys.length; i++) {
  4. var key = keys[i];
  5. var value = Object.getOwnPropertyDescriptor(defaults, key);
  6. if (value && value.configurable && obj[key] === undefined) {
  7. Object.defineProperty(obj, key, value);
  8. }
  9. }
  10. return obj;
  11. }