Skip to content

Commit

Permalink
[Refactor] use define-data-property
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Sep 13, 2023
1 parent 8205f97 commit e7782a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
16 changes: 5 additions & 11 deletions index.js
Expand Up @@ -5,15 +5,13 @@ var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbo

var toStr = Object.prototype.toString;
var concat = Array.prototype.concat;
var origDefineProperty = Object.defineProperty;
var defineDataProperty = require('define-data-property');

var isFunction = function (fn) {
return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
};

var hasPropertyDescriptors = require('has-property-descriptors')();

var supportsDescriptors = origDefineProperty && hasPropertyDescriptors;
var supportsDescriptors = require('has-property-descriptors')();

var defineProperty = function (object, name, value, predicate) {
if (name in object) {
Expand All @@ -25,15 +23,11 @@ var defineProperty = function (object, name, value, predicate) {
return;
}
}

if (supportsDescriptors) {
origDefineProperty(object, name, {
configurable: true,
enumerable: false,
value: value,
writable: true
});
defineDataProperty(object, name, value, true);
} else {
object[name] = value; // eslint-disable-line no-param-reassign
defineDataProperty(object, name, value);
}
};

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -34,6 +34,7 @@
"ES5"
],
"dependencies": {
"define-data-property": "^1.0.1",
"has-property-descriptors": "^1.0.0",
"object-keys": "^1.1.1"
},
Expand Down

0 comments on commit e7782a7

Please sign in to comment.