You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
370 B

4 years ago
  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. }