Skip to content

Commit

Permalink
[patch] remove GetKeysIterator and its callable check
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 18, 2023
1 parent 09b9244 commit 4bf3ce8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"RequireObjectCoercible",
"GetIntrinsic",
"GetSetRecord",
"GetKeysIterator",
"GetIteratorFromMethod",
"IteratorStep",
"IteratorValue",
"SetDataHas",
Expand All @@ -21,7 +21,6 @@
"Get",
"ToNumber",
"Type",
// GetKeysIterator
"Type",
"Call",
"Get",
Expand Down
25 changes: 25 additions & 0 deletions aos/GetIteratorFromMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

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

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

var Call = require('es-abstract/2023/Call');
var Get = require('es-abstract/2023/Get');
var Type = require('es-abstract/2023/Type');

// https://tc39.es/ecma262/#sec-getiteratorfrommethod

module.exports = function GetIteratorFromMethod(obj, method) {
var iterator = Call(method, obj); // step 1

if (Type(iterator) !== 'Object') {
throw new $TypeError('iterator must return an object'); // step 2
}

var nextMethod = Get(iterator, 'next'); // step 3

var iteratorRecord = { '[[Iterator]]': iterator, '[[NextMethod]]': nextMethod, '[[Done]]': false }; // step 4

return iteratorRecord; // step 5
};
31 changes: 0 additions & 31 deletions aos/GetKeysIterator.js

This file was deleted.

4 changes: 2 additions & 2 deletions implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var $TypeError = GetIntrinsic('%TypeError%');

var $Set = require('es-set/polyfill')();

var GetKeysIterator = require('./aos/GetKeysIterator');
var GetIteratorFromMethod = require('./aos/GetIteratorFromMethod');
var GetSetRecord = require('./aos/GetSetRecord');
var IteratorStep = require('es-abstract/2023/IteratorStep');
var IteratorValue = require('es-abstract/2023/IteratorValue');
Expand All @@ -28,7 +28,7 @@ module.exports = function union(other) {

var otherRec = GetSetRecord(other); // step 3

var keysIter = GetKeysIterator(otherRec); // step 4
var keysIter = GetIteratorFromMethod(otherRec['[[Set]]'], otherRec['[[Keys]]']); // step 4

// 5. Let resultSetData be a copy of O.[[SetData]]; // step 5
var result = new $Set();
Expand Down

0 comments on commit 4bf3ce8

Please sign in to comment.