Skip to content

Commit

Permalink
[Refactor] use es-define-property
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Feb 13, 2024
1 parent 35e9b46 commit f93a8c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
'use strict';

var GetIntrinsic = require('get-intrinsic');

var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
var $defineProperty = require('es-define-property');

var hasPropertyDescriptors = function hasPropertyDescriptors() {
if ($defineProperty) {
try {
$defineProperty({}, 'a', { value: 1 });
return true;
} catch (e) {
// IE 8 has a broken defineProperty
return false;
}
}
return false;
return !!$defineProperty;
};

hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
// node v0.6 has a bug where array lengths can be Set but not Defined
if (!hasPropertyDescriptors()) {
if (!$defineProperty) {
return null;
}
try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"tape": "^5.7.4"
},
"dependencies": {
"get-intrinsic": "^1.2.4"
"es-define-property": "^1.0.0"
},
"testling": {
"files": "test/index.js"
Expand Down

0 comments on commit f93a8c8

Please sign in to comment.