Skip to content

Commit

Permalink
[Refactor] use set-function-name
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Sep 13, 2023
1 parent dd9a97c commit 126714d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
18 changes: 4 additions & 14 deletions implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ var GetIntrinsic = require('get-intrinsic');

var ArrayCreate = require('es-abstract/2023/ArrayCreate');
var CreateDataPropertyOrThrow = require('es-abstract/2023/CreateDataPropertyOrThrow');
var DefinePropertyOrThrow = require('es-abstract/2023/DefinePropertyOrThrow');
var Get = require('es-abstract/2023/Get');
var ToIntegerOrInfinity = require('es-abstract/2023/ToIntegerOrInfinity');
var LengthOfArrayLike = require('es-abstract/2023/LengthOfArrayLike');
var ToObject = require('es-abstract/2023/ToObject');
var ToString = require('es-abstract/2023/ToString');

var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();

var $RangeError = GetIntrinsic('%RangeError%');

module.exports = function With(index, value) {
var setFunctionName = require('set-function-name');

module.exports = setFunctionName(function With(index, value) {
var O = ToObject(this); // step 1
var len = LengthOfArrayLike(O); // step 2
var relativeIndex = ToIntegerOrInfinity(index); // step 3
Expand All @@ -35,13 +34,4 @@ module.exports = function With(index, value) {
}

return A; // step 10
};

if (functionsHaveConfigurableNames) {
DefinePropertyOrThrow(module.exports, 'name', {
'[[Configurable]]': true,
'[[Enumerable]]': false,
'[[Value]]': 'with',
'[[Writable]]': false
});
}
}, 'with', true);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"eslint": "=8.8.0",
"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"functions-have-names": "^1.2.3",
"has": "^1.0.3",
"has-strict-mode": "^1.0.1",
"in-publish": "^2.0.1",
Expand All @@ -65,8 +66,8 @@
"call-bind": "^1.0.2",
"define-properties": "^1.2.0",
"es-abstract": "^1.22.1",
"functions-have-names": "^1.2.3",
"get-intrinsic": "^1.2.1"
"get-intrinsic": "^1.2.1",
"set-function-name": "^2.0.0"
},
"auto-changelog": {
"output": "CHANGELOG.md",
Expand Down

0 comments on commit 126714d

Please sign in to comment.