diff --git a/.eslintrc b/.eslintrc index d17a8d5..e69f080 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,9 +10,13 @@ "max-statements": 0, "new-cap": [2, { "capIsNewExceptions": [ + "AddEntriesFromIterable", "ArrayFrom", "Call", "CreateIterResultObject", + "CreateMethodProperty", + "DefinePropertyOrThrow", + "Get", "GetIntrinsic", "GetIterator", "HasOwnProperty", diff --git a/implementation.js b/implementation.js index 46a1720..636f09a 100644 --- a/implementation.js +++ b/implementation.js @@ -4,8 +4,8 @@ var define = require('define-properties'); var callBound = require('call-bind/callBound'); var GetIntrinsic = require('get-intrinsic'); var SLOT = require('internal-slot'); -var SameValue = require('es-abstract/2020/SameValue'); -var SameValueZero = require('es-abstract/2020/SameValueZero'); +var SameValue = require('es-abstract/2021/SameValue'); +var SameValueZero = require('es-abstract/2021/SameValueZero'); var MapEntry = require('./lib/map-entry'); var MapIterator = require('./lib/map-iterator'); diff --git a/lib/helpers.js b/lib/helpers.js index f7eca3e..e0eab36 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -1,13 +1,13 @@ 'use strict'; -var define = require('define-properties'); var hasSymbols = require('has-symbols')(); var GetIntrinsic = require('get-intrinsic'); var SLOT = require('internal-slot'); var entries = require('object.entries'); var forEach = require('foreach'); -var OrdinaryObjectCreate = require('es-abstract/2020/OrdinaryObjectCreate'); -var Type = require('es-abstract/2020/Type'); +var CreateMethodProperty = require('es-abstract/2021/CreateMethodProperty'); +var OrdinaryObjectCreate = require('es-abstract/2021/OrdinaryObjectCreate'); +var Type = require('es-abstract/2021/Type'); var $ObjectCreate = GetIntrinsic('%Object.create%', true); @@ -79,19 +79,9 @@ exports.addIterator = function (prototype, impl) { // eslint-disable-next-line no-invalid-this return this; }; - if (define.supportsDescriptors) { - Object.defineProperty(prototype, $iterator$, { - configurable: true, - enumerable: false, - value: implementation, - writable: true - }); - if (!prototype[$iterator$] && Type($iterator$) === 'Symbol') { - // implementations are buggy when $iterator$ is a Symbol - // eslint-disable-next-line no-param-reassign - prototype[$iterator$] = implementation; - } - } else { + CreateMethodProperty(prototype, $iterator$, implementation); + if (!prototype[$iterator$] && Type($iterator$) === 'Symbol') { + // implementations are buggy when $iterator$ is a Symbol // eslint-disable-next-line no-param-reassign prototype[$iterator$] = implementation; } diff --git a/lib/map-helpers.js b/lib/map-helpers.js index 73715af..81aab69 100644 --- a/lib/map-helpers.js +++ b/lib/map-helpers.js @@ -1,12 +1,12 @@ 'use strict'; -var ToString = require('es-abstract/2020/ToString'); -var Type = require('es-abstract/2020/Type'); -var IsArray = require('es-abstract/2020/IsArray'); -var IsCallable = require('es-abstract/2020/IsCallable'); -var IteratorStep = require('es-abstract/2020/IteratorStep'); -var IteratorClose = require('es-abstract/2020/IteratorClose'); -var Call = require('es-abstract/2020/Call'); +var Call = require('es-abstract/2021/Call'); +var IsArray = require('es-abstract/2021/IsArray'); +var IsCallable = require('es-abstract/2021/IsCallable'); +var IteratorClose = require('es-abstract/2021/IteratorClose'); +var IteratorStep = require('es-abstract/2021/IteratorStep'); +var ToString = require('es-abstract/2021/ToString'); +var Type = require('es-abstract/2021/Type'); var GetIterator = require('es-get-iterator'); var MapIterator = require('./map-iterator'); diff --git a/lib/map-iterator.js b/lib/map-iterator.js index 4949fcf..0dc5fed 100644 --- a/lib/map-iterator.js +++ b/lib/map-iterator.js @@ -1,12 +1,13 @@ 'use strict'; -var define = require('define-properties'); var hasSymbols = require('has-symbols')(); var SLOT = require('internal-slot'); var GetIntrinsic = require('get-intrinsic'); -var CreateIterResultObject = require('es-abstract/2020/CreateIterResultObject'); -var OrdinaryObjectCreate = require('es-abstract/2020/OrdinaryObjectCreate'); +var CreateIterResultObject = require('es-abstract/2021/CreateIterResultObject'); +var CreateMethodProperty = require('es-abstract/2021/CreateMethodProperty'); +var DefinePropertyOrThrow = require('es-abstract/2021/DefinePropertyOrThrow'); +var OrdinaryObjectCreate = require('es-abstract/2021/OrdinaryObjectCreate'); var requireMapSlot = require('./validation').requireMapSlot; var addIterator = require('./helpers').addIterator; @@ -28,8 +29,11 @@ if (IteratorPrototype) { } addIterator(MapIterator.prototype); -define(MapIterator.prototype, { - next: function next() { +CreateMethodProperty( + MapIterator.prototype, + 'next', + function next() { + /* eslint no-invalid-this: 0 */ if (!SLOT.has(this, '[[isMapIterator]]')) { throw new TypeError('Not a MapIterator'); } @@ -63,14 +67,14 @@ define(MapIterator.prototype, { SLOT.set(this, '[[i]]', void undefined); return CreateIterResultObject(void undefined, true); } -}); +); if (hasSymbols && Symbol.toStringTag) { - Object.defineProperty(MapIterator.prototype, Symbol.toStringTag, { - configurable: true, - enumerable: false, - value: 'Map Iterator', - writable: false + DefinePropertyOrThrow(MapIterator.prototype, Symbol.toStringTag, { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': 'Map Iterator', + '[[Writable]]': false }); } diff --git a/lib/validation.js b/lib/validation.js index bc5e2bb..be78567 100644 --- a/lib/validation.js +++ b/lib/validation.js @@ -1,8 +1,8 @@ 'use strict'; var SLOT = require('internal-slot'); -var ToString = require('es-abstract/2020/ToString'); -var Type = require('es-abstract/2020/Type'); +var ToString = require('es-abstract/2021/ToString'); +var Type = require('es-abstract/2021/Type'); var isMap = function isMap(map) { return SLOT.has(map, '[[es6map]]'); diff --git a/package.json b/package.json index 6e839af..3042944 100644 --- a/package.json +++ b/package.json @@ -66,16 +66,16 @@ "tape": "^5.3.1" }, "dependencies": { - "call-bind": "^1.0.0", + "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.1", - "es-get-iterator": "^1.1.1", + "es-abstract": "^1.19.1", + "es-get-iterator": "^1.1.2", "for-each": "^0.3.3", - "get-intrinsic": "^1.0.2", - "globalthis": "^1.0.1", - "has-symbols": "^1.0.1", - "internal-slot": "^1.0.2", - "object.entries": "^1.1.3" + "get-intrinsic": "^1.1.1", + "globalthis": "^1.0.2", + "has-symbols": "^1.0.2", + "internal-slot": "^1.0.3", + "object.entries": "^1.1.5" }, "auto-changelog": { "output": "CHANGELOG.md", diff --git a/shim.js b/shim.js index 4b194d0..7aa9ea9 100644 --- a/shim.js +++ b/shim.js @@ -7,8 +7,8 @@ var getPolyfill = require('./polyfill'); var support = require('./lib/support'); var addIterableToMap = require('./lib/map-helpers').addIterableToMap; -var OrdinarySetPrototypeOf = require('es-abstract/2020/OrdinarySetPrototypeOf'); -var Call = require('es-abstract/2020/Call'); +var OrdinarySetPrototypeOf = require('es-abstract/2021/OrdinarySetPrototypeOf'); +var Call = require('es-abstract/2021/Call'); var force = function () { return true; diff --git a/test/tests.js b/test/tests.js index 77c7b80..4982ecb 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,11 +1,11 @@ 'use strict'; -var HasOwnProperty = require('es-abstract/2020/HasOwnProperty'); +var HasOwnProperty = require('es-abstract/2021/HasOwnProperty'); var isEnumerable = Object.prototype.propertyIsEnumerable; var functionsHaveNames = require('functions-have-names')(); var define = require('define-properties'); var hasSymbols = require('has-symbols')(); -var ArrayFrom = require('array.from').implementation; +var ArrayFrom = require('array.from/implementation'); // eslint-disable-next-line max-params var testMapping = function testMapping(t, map, key, value, desc) {