es-iterator-helpers
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -8,3 +8,2 @@ 'use strict'; | ||
var Get = require('es-abstract/2022/Get'); | ||
var IsCallable = require('es-abstract/2022/IsCallable'); | ||
var Type = require('es-abstract/2022/Type'); | ||
@@ -19,9 +18,5 @@ | ||
if (!IsCallable(nextMethod)) { | ||
throw new $TypeError('`nextMethod` must be a function'); // step 3 | ||
} | ||
var iteratorRecord = { '[[Iterator]]': obj, '[[NextMethod]]': nextMethod, '[[Done]]': false }; // step 3 | ||
var iteratorRecord = { '[[Iterator]]': obj, '[[NextMethod]]': nextMethod, '[[Done]]': false }; // step 4 | ||
return iteratorRecord; // step 5 | ||
return iteratorRecord; // step 4 | ||
}; |
@@ -10,5 +10,4 @@ 'use strict'; | ||
var GetIteratorDirect = require('./GetIteratorDirect'); | ||
var GetV = require('es-abstract/2022/GetV'); | ||
var GetMethod = require('es-abstract/2022/GetMethod'); | ||
var IsArray = require('es-abstract/2022/IsArray'); | ||
var IsCallable = require('es-abstract/2022/IsCallable'); | ||
var Type = require('es-abstract/2022/Type'); | ||
@@ -25,7 +24,7 @@ | ||
// method = Get(obj, Symbol.iterator); // step 5.a | ||
// method = GetMethod(obj, Symbol.iterator); // step 5.a | ||
method = getIteratorMethod( | ||
{ | ||
AdvanceStringIndex: AdvanceStringIndex, | ||
GetMethod: GetV, | ||
GetMethod: GetMethod, | ||
IsArray: IsArray | ||
@@ -37,3 +36,3 @@ }, | ||
var iterator; | ||
if (!IsCallable(method)) { // step 3 | ||
if (typeof method === 'undefined') { // step 3 | ||
iterator = obj; // step 3.a | ||
@@ -40,0 +39,0 @@ } else { // step 4 |
@@ -8,2 +8,12 @@ # Changelog | ||
## [v1.0.10](https://github.com/es-shims/iterator-helpers/compare/v1.0.9...v1.0.10) - 2023-05-18 | ||
### Commits | ||
- [patch] remove IsCallable check on NextMethod, deferring errors to callsite [`bbb7efa`](https://github.com/es-shims/iterator-helpers/commit/bbb7efac8349273fe17c86194ef13af45bcb8e24) | ||
- [patch] change Symbol.iterator fallback from callable check to nullish check [`ec3e255`](https://github.com/es-shims/iterator-helpers/commit/ec3e255dfe30ea6650d8a697e6c4f16fa393e923) | ||
- [Tests] add test cases [`5117c47`](https://github.com/es-shims/iterator-helpers/commit/5117c477348407ebdfc9410dd437a68634c39a8e) | ||
- [Dev Deps] update `@es-shims/api` [`9fa13a0`](https://github.com/es-shims/iterator-helpers/commit/9fa13a0739f353536de58b2b648aa9eacfa49479) | ||
- [Dev Deps] update `@es-shims/api` [`b74b0ac`](https://github.com/es-shims/iterator-helpers/commit/b74b0ac2bd7e920f760bae7ba7c6c5310f5123d8) | ||
## [v1.0.9](https://github.com/es-shims/iterator-helpers/compare/v1.0.8...v1.0.9) - 2023-05-02 | ||
@@ -10,0 +20,0 @@ |
{ | ||
"name": "es-iterator-helpers", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3.", | ||
@@ -141,3 +141,3 @@ "main": "index.json", | ||
"devDependencies": { | ||
"@es-shims/api": "^2.3.1", | ||
"@es-shims/api": "^2.4.2", | ||
"@ljharb/eslint-config": "^21.0.1", | ||
@@ -144,0 +144,0 @@ "aud": "^2.0.2", |
@@ -45,3 +45,3 @@ 'use strict'; | ||
t['throws']( | ||
function () { from(nonIterator); }, | ||
function () { from(nonIterator).next(); }, | ||
TypeError, | ||
@@ -58,3 +58,3 @@ debug(nonIterator) + ' is not an iterable Object' | ||
st['throws']( | ||
function () { from(badIterable); }, | ||
function () { from(badIterable).next(); }, | ||
TypeError, | ||
@@ -61,0 +61,0 @@ debug(badIterable) + ' is not a function' |
@@ -13,2 +13,3 @@ 'use strict'; | ||
var hasPropertyDescriptors = require('has-property-descriptors')(); | ||
var iterate = require('iterate-iterator'); | ||
@@ -28,3 +29,3 @@ var index = require('../Iterator.prototype.drop'); | ||
t['throws']( | ||
function () { drop(nonIterator, 0); }, | ||
function () { iterate(drop(nonIterator, 0)); }, | ||
TypeError, | ||
@@ -36,3 +37,3 @@ debug(nonIterator) + ' is not an Object with a callable `next` method' | ||
t['throws']( | ||
function () { drop(badNext, 0); }, | ||
function () { iterate(drop(badNext, 0)); }, | ||
TypeError, | ||
@@ -39,0 +40,0 @@ debug(badNext) + ' is not an Object with a callable `next` method' |
@@ -79,4 +79,5 @@ 'use strict'; | ||
testIterator(flatMap(iterator(), function (x) { return [[x]][Symbol.iterator](); }), [[1], [2], [3]], st, 'identity mapper in nested array iterator'); | ||
testIterator(flatMap(iterator(), function (x) { return [[2 * x]][Symbol.iterator](); }), [[2], [4], [6]], st, 'doubler mapper in nested array iterator'); | ||
testIterator(flatMap(iterator(), function () { return []; }), [], st, 'empty mapper in nested array iterator'); | ||
testIterator(flatMap(iterator(), function (x) { return [[x, x + 1]][Symbol.iterator](); }), [[1, 2], [2, 3], [3, 4]], st, 'identity mapper in nested array iterator'); | ||
testIterator(flatMap(iterator(), function (x) { return [[2 * x, 2 * (x + 1)]][Symbol.iterator](); }), [[2, 4], [4, 6], [6, 8]], st, 'doubler mapper in nested array iterator'); | ||
@@ -119,3 +120,3 @@ testIterator(flatMap([0, 1, 2, 3][Symbol.iterator](), function (value) { | ||
}; | ||
ret[Symbol.iterator] = 0; | ||
ret[Symbol.iterator] = null; | ||
return ret; | ||
@@ -122,0 +123,0 @@ }), [0, 1, 2], st, 'test262: test/built-ins/Iterator/prototype/flatMap/iterable-to-iterator-fallback'); |
@@ -26,3 +26,3 @@ 'use strict'; | ||
t['throws']( | ||
function () { take(nonIterator, 0); }, | ||
function () { take(nonIterator, 1).next(); }, | ||
TypeError, | ||
@@ -32,8 +32,10 @@ debug(nonIterator) + ' is not an Object with a callable `next` method' | ||
var badNext = { next: nonIterator }; | ||
t['throws']( | ||
function () { take(badNext, 0); }, | ||
TypeError, | ||
debug(badNext) + ' is not an Object with a callable `next` method' | ||
); | ||
if (nonIterator != null && typeof nonIterator !== 'string') { | ||
var badNext = { next: nonIterator }; | ||
t['throws']( | ||
function () { take(badNext, 1).next(); }, | ||
TypeError, | ||
debug(badNext) + ' is not an Object with a callable `next` method' | ||
); | ||
} | ||
}); | ||
@@ -40,0 +42,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141589
3358