main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

67
node_modules/es-iterator-helpers/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"root": true,
"extends": "@ljharb",
"plugins": [
"import",
],
"globals": {
"Iterator": false,
},
"rules": {
"array-bracket-newline": 0,
"func-name-matching": 0,
"id-length": 0,
"max-lines-per-function": 0,
"max-statements": 0,
"multiline-comment-style": 0,
"new-cap": [2, {
"capIsNewExceptions": [
"Call",
"CreateIteratorFromClosure",
"CreateIterResultObject",
"GeneratorResume",
"GeneratorResumeAbrupt",
"GeneratorStart",
"GeneratorValidate",
"Get",
"GetIntrinsic",
"GetIteratorDirect",
"GetIteratorFlattenable",
"GetMethod",
"IsArray",
"IsCallable",
"IteratorClose",
"IteratorStepValue",
"IteratorStep",
"NormalCompletion",
"OrdinaryHasInstance",
"OrdinaryObjectCreate",
"StringToCodePoints",
"ThrowCompletion",
"ToBoolean",
"ToIntegerOrInfinity",
"ToNumber",
"Type",
],
}],
"no-negated-condition": 1,
"object-curly-newline": 0,
"sort-keys": 0,
"import/no-extraneous-dependencies": 2,
},
"overrides": [
{
"files": "test/**",
"rules": {
"eqeqeq": ["error", "allow-null"],
"max-params": 0,
"import/no-extraneous-dependencies": [2, { "devDependencies": true }],
},
},
],
}

12
node_modules/es-iterator-helpers/.github/FUNDING.yml generated vendored Normal file
View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/es-iterator-helpers
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

13
node_modules/es-iterator-helpers/.nycrc generated vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"test"
]
}

185
node_modules/es-iterator-helpers/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,185 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.1.0](https://github.com/es-shims/iterator-helpers/compare/v1.0.19...v1.1.0) - 2024-10-09
### Commits
- [New] add `Iterator.concat` [`1c07c21`](https://github.com/es-shims/iterator-helpers/commit/1c07c21d42fa6f3de516191a2b7fb848679314e7)
- [readme] add ESM and CJS examples [`ae0b60c`](https://github.com/es-shims/iterator-helpers/commit/ae0b60cae42a5e6174809859e29d16085042e3b2)
- [Dev Deps] update `@es-shims/api`, `auto-changelog`, `es-value-fixtures`, `eslint-plugin-import`, `tape` [`bd34766`](https://github.com/es-shims/iterator-helpers/commit/bd34766d527cc625dcbc242297290a793f21b055)
- [Dev Deps] update `@ljharb/eslint-config`, `mock-property`, `object-inspect`, `tape` [`2016080`](https://github.com/es-shims/iterator-helpers/commit/201608082a32bc1fa114c012eeb72744e1bf5bfa)
- [readme] fix copy-paste errors [`799255c`](https://github.com/es-shims/iterator-helpers/commit/799255ce358f9f19ab54cc2377aafb404463d917)
- [Tests] replace `aud` with `npm audit` [`4c48a77`](https://github.com/es-shims/iterator-helpers/commit/4c48a77d90a6894863ad160fd0f88b3fc76653b6)
- [Deps] update `globalthis` [`14d9e97`](https://github.com/es-shims/iterator-helpers/commit/14d9e971f976da482cbb7ee76b583db9ce17e056)
- [Dev Deps] update `@es-shims/api` [`15d84bb`](https://github.com/es-shims/iterator-helpers/commit/15d84bbbe1864dfd028f30f98251cbdf19e74908)
- [Dev Deps] add missing peer dep [`34559b9`](https://github.com/es-shims/iterator-helpers/commit/34559b9a263dfbc3551fd0ff586639692c04e514)
## [v1.0.19](https://github.com/es-shims/iterator-helpers/compare/v1.0.18...v1.0.19) - 2024-04-24
### Commits
- [patch] remove unused AOs [`698cef7`](https://github.com/es-shims/iterator-helpers/commit/698cef79757378a74500690d5a5dc2a6b86cd304)
- [Fix] `drop`, `filter`, `flatMap`, `map`: rpatch a v8 bug when polyfilling [`3670395`](https://github.com/es-shims/iterator-helpers/commit/36703956321c201933c4c701c78304669a46947b)
- [Deps] update `es-abstract` [`d2b47a5`](https://github.com/es-shims/iterator-helpers/commit/d2b47a5f46d3f874aad67375346cb58bf8c9e8b2)
## [v1.0.18](https://github.com/es-shims/iterator-helpers/compare/v1.0.17...v1.0.18) - 2024-03-15
### Commits
- [Deps] update `es-abstract` [`6b45f15`](https://github.com/es-shims/iterator-helpers/commit/6b45f150e939cfbf93b816431a407c0838250e85)
- [Deps] update `es-set-tostringtag`, `has-proto`, `safe-array-concat` [`6350106`](https://github.com/es-shims/iterator-helpers/commit/6350106c9e5c18a67754ced3fd90465b0032f1e3)
- [Dev Deps] update `tape` [`5509b40`](https://github.com/es-shims/iterator-helpers/commit/5509b408791402d2f7d7882f905741e5a5dd805b)
- [Deps] remove an unused dep [`78e34a5`](https://github.com/es-shims/iterator-helpers/commit/78e34a5452e7b7ef3dc239a62dd8a7324fbb2305)
## [v1.0.17](https://github.com/es-shims/iterator-helpers/compare/v1.0.16...v1.0.17) - 2024-02-13
### Fixed
- [Fix] avoid use of internal `assertRecord` helper from `es-abstract` [`#5`](https://github.com/es-shims/iterator-helpers/issues/5)
### Commits
- [Deps] update `call-bind`, `es-abstract`, `has-property-descriptors` [`e563ee7`](https://github.com/es-shims/iterator-helpers/commit/e563ee7230897c41f7f3623a11fc0ecc6862ee1c)
## [v1.0.16](https://github.com/es-shims/iterator-helpers/compare/v1.0.15...v1.0.16) - 2024-02-09
### Commits
- [Refactor] use `IteratorStepValue` [`aa62d72`](https://github.com/es-shims/iterator-helpers/commit/aa62d72c52d86218942b4792c7131f72d939b733)
- [Refactor] use `es-errors` instead of `get-intrinsic` where possible [`05a25ae`](https://github.com/es-shims/iterator-helpers/commit/05a25aeccd0523df86b401c771d88fbea06558c9)
- [Deps] update `call-bind`, `es-abstract`, `es-set-tostringtag`, `function-bind`, `get-intrinsic`, `has-property-descriptors`, `internal-slot`, `safe-array-concat` [`6aeee43`](https://github.com/es-shims/iterator-helpers/commit/6aeee435ed5956b7c5ee66a51b86c26827874eae)
- [Dev Deps] update `aud`, `eslint-plugin-import`, `mock-property`, `npmignore`, `object-inspect`, `tape` [`0a21fdb`](https://github.com/es-shims/iterator-helpers/commit/0a21fdb4a59d25c248561b7f476fc9670b411855)
- [Deps] update `call-bind`, `es-errors`, `get-intrinsic`, `internal-slot` [`5b10625`](https://github.com/es-shims/iterator-helpers/commit/5b106251dad4252a744b2e0aa0d1be4c1c62b779)
- [meta] add missing `engines.node` [`1534039`](https://github.com/es-shims/iterator-helpers/commit/1534039eca062429c0df68dcc3459ce9ba7c69be)
- [Deps] update `get-intrinsic` [`37da5f2`](https://github.com/es-shims/iterator-helpers/commit/37da5f201940c78526de647ef9ba84d9152349c1)
- [Dev Deps] update `has-tostringtag` [`a7cac51`](https://github.com/es-shims/iterator-helpers/commit/a7cac51cc027e6274918cb1ea0cf1fa1a194fcd9)
## [v1.0.15](https://github.com/es-shims/iterator-helpers/compare/v1.0.14...v1.0.15) - 2023-09-13
### Commits
- [New] add `Iterator.prototype` shim [`c4a6203`](https://github.com/es-shims/iterator-helpers/commit/c4a6203a0ac87bf0a33835e775c207ff1911225d)
- [Tests] add passing tests for native generators [`57bae8c`](https://github.com/es-shims/iterator-helpers/commit/57bae8ccbeb27ed0e6c449f35cddbda6cf6757e8)
- [Deps] update `define-properties`, `iterator.prototype`, `safe-array-concat` [`56ca087`](https://github.com/es-shims/iterator-helpers/commit/56ca087f924dbefee47f0a1cb3b8468de76cd234)
## [v1.0.14](https://github.com/es-shims/iterator-helpers/compare/v1.0.13...v1.0.14) - 2023-08-26
### Commits
- [Deps] update `es-abstract` [`477b123`](https://github.com/es-shims/iterator-helpers/commit/477b1233acd36fdbbccd79fbb69cde325bc3e6a9)
- [Dev Deps] update `aud`, `eslint-plugin-import`, `tape` [`e4ea414`](https://github.com/es-shims/iterator-helpers/commit/e4ea4146feffb72fd828e5d883e960e0ad589a35)
## [v1.0.13](https://github.com/es-shims/iterator-helpers/compare/v1.0.12...v1.0.13) - 2023-08-16
### Fixed
- [Deps] add missing deps; add eslint-plugin-import [`#3`](https://github.com/es-shims/iterator-helpers/issues/3)
## [v1.0.12](https://github.com/es-shims/iterator-helpers/compare/v1.0.11...v1.0.12) - 2023-07-14
### Commits
- [Fix] avoid creating string wrapper objects with sloppy mode flatMap mappers [`db16b34`](https://github.com/es-shims/iterator-helpers/commit/db16b34aec554934ec2bfd62629fb66cebc311f8)
- [Deps] update `es-abstract` [`f002147`](https://github.com/es-shims/iterator-helpers/commit/f002147f0afbb2cd7c2d2e1207685f52e33abf0f)
- [Dev Deps] update `@ljharb/eslint-config`, `aud [`42064e8`](https://github.com/es-shims/iterator-helpers/commit/42064e80e0cc37f5e4676c2133dacae7456e313f)
- [meta] fix tidelift funding identifier [`896fd4f`](https://github.com/es-shims/iterator-helpers/commit/896fd4f2e4b419945bfbd85024a2c96248323151)
## [v1.0.11](https://github.com/es-shims/iterator-helpers/compare/v1.0.10...v1.0.11) - 2023-05-22
### Commits
- [Fix] iterator helpers are not a constructor [`8a7f999`](https://github.com/es-shims/iterator-helpers/commit/8a7f9996ba3600ef30f3a9c75f9f994e88d075c6)
## [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
### Commits
- [Refactor] use 2022 AO instead of 2015 AO [`75ee5c4`](https://github.com/es-shims/iterator-helpers/commit/75ee5c4dea0037f02a61c240114bb6bd8c8b48f1)
## [v1.0.8](https://github.com/es-shims/iterator-helpers/compare/v1.0.7...v1.0.8) - 2023-05-02
### Commits
- [Fix] `flatMap`: close the inner iterator when applicable [`4dc94e0`](https://github.com/es-shims/iterator-helpers/commit/4dc94e0117e34b4c99f9ed96c4fe306896c47da1)
## [v1.0.7](https://github.com/es-shims/iterator-helpers/compare/v1.0.6...v1.0.7) - 2023-05-01
### Commits
- [Fix] `flatMap`: properly handle yielded iterables [`3a78767`](https://github.com/es-shims/iterator-helpers/commit/3a78767e86394d45b212a225e4253745f8b1dc8d)
- [Fix] `flatMap`: only increment the count when iterating the outer iterator [`955d0b0`](https://github.com/es-shims/iterator-helpers/commit/955d0b00f5660db0d9febef2a16426dfc32e8be4)
## [v1.0.6](https://github.com/es-shims/iterator-helpers/compare/v1.0.5...v1.0.6) - 2023-04-20
### Commits
- [Refactor] `GetIteratorFlattenable`: remove hint [`781fc7c`](https://github.com/es-shims/iterator-helpers/commit/781fc7c28615aaaef139cbcd9e6ade513419bea1)
- [Refactor] `GetIteratorFlattenable`: use `GetIteratorDirect` [`026118b`](https://github.com/es-shims/iterator-helpers/commit/026118b8c884adaee5ab0eb12de838ef9abdbb6f)
- [Refactor] use `safe-array-concat` [`1d985a4`](https://github.com/es-shims/iterator-helpers/commit/1d985a449be212523f05ba4a359a162931ddf3d3)
## [v1.0.5](https://github.com/es-shims/iterator-helpers/compare/v1.0.4...v1.0.5) - 2023-03-22
### Commits
- [Tests] add passing tests for 4240029 [`c2082fe`](https://github.com/es-shims/iterator-helpers/commit/c2082fee3e73dc1998a67fbe0014e3ebdceb8ec0)
- [Fix] properly allow subclasses of Iterator to be constructed [`5cebe2a`](https://github.com/es-shims/iterator-helpers/commit/5cebe2a5767393696d0ce4e9325edf78c300f938)
## [v1.0.4](https://github.com/es-shims/iterator-helpers/compare/v1.0.3...v1.0.4) - 2023-03-21
### Commits
- [Fix] validate arguments first [`4240029`](https://github.com/es-shims/iterator-helpers/commit/42400297454909ddccc899a012dc55bbd403eb8b)
- [Fix] close underlying iterator when helper is closed [`f5372c7`](https://github.com/es-shims/iterator-helpers/commit/f5372c78cafff64bfda5849386538f806916049a)
- [Tests] `Iterator`: remove an unnecessary call-bind [`7d0ba59`](https://github.com/es-shims/iterator-helpers/commit/7d0ba59f672e690b189f91e0348f6b5e00f934e1)
## [v1.0.3](https://github.com/es-shims/iterator-helpers/compare/v1.0.2...v1.0.3) - 2023-03-17
### Commits
- [Fix] `drop`/`filter`/`flatMap`/`map`/`take`: properly IfAbruptCloseIterator [`ff643a0`](https://github.com/es-shims/iterator-helpers/commit/ff643a0b7c4e5c2b00e794ba9b988b47e783f235)
- [Refactor] use `NormalCompletion`/`ThrowCompletion` instead of thunks [`68fd937`](https://github.com/es-shims/iterator-helpers/commit/68fd937b53c107481a9f868bda5b2bd5cbc00142)
- [Fix] `filter`: IteratorClose needs to rethrow the error [`200474f`](https://github.com/es-shims/iterator-helpers/commit/200474ff289dea77c696c0c025f4602405cf3fff)
- [Fix] `filter`: properly increment the counter [`14aa2d8`](https://github.com/es-shims/iterator-helpers/commit/14aa2d8b75fd16378c2be183fd5b008712547ed4)
- [Fix] `Iterator` can not be `new`ed or invoked directly [`6fbd68e`](https://github.com/es-shims/iterator-helpers/commit/6fbd68e778dd455c4aa63f4e1f39e0b583610509)
- [Fix] `Iterator.prototype` should be non-writable [`1080288`](https://github.com/es-shims/iterator-helpers/commit/108028858067e40ea56dca9a68dd6cea4966e904)
- [Deps] update `es-abstract` [`b7913da`](https://github.com/es-shims/iterator-helpers/commit/b7913da9cddef1ec40b4827821c6069019b79093)
- [Dev Deps] update `@es-shims/api` [`0071bed`](https://github.com/es-shims/iterator-helpers/commit/0071bed9e13231317d2cdb9ae0ecb6603784ad1f)
## [v1.0.2](https://github.com/es-shims/iterator-helpers/compare/v1.0.1...v1.0.2) - 2023-02-09
### Commits
- [Refactor] inline 2023 impls of Iterator AOs until es-abstract is published with them [`b9c80c5`](https://github.com/es-shims/iterator-helpers/commit/b9c80c5aba0deaaabef7e650fe7ec231fdc695e3)
- [Fix] ensure calling `.return` does not invoke the next iteration [`9e28ed5`](https://github.com/es-shims/iterator-helpers/commit/9e28ed5af44a660a0d2e80684cb9a4bf3d86e09a)
- [Fix] `map`: pass the proper index argument to the mapper [`125e3ca`](https://github.com/es-shims/iterator-helpers/commit/125e3cac192ef650a88f774a5a2dd9afe395a5b8)
- [Deps] update `internal-slot` [`43351b6`](https://github.com/es-shims/iterator-helpers/commit/43351b63545e3698f54daf5dc0652a7b2fb7cb28)
## [v1.0.1](https://github.com/es-shims/iterator-helpers/compare/v1.0.0...v1.0.1) - 2023-02-07
### Commits
- [Fix] `Iterator`: throw when Iterator() is called without new [`a6fc7e7`](https://github.com/es-shims/iterator-helpers/commit/a6fc7e768cbf4d43117365ec2f1bd300247d8dfd)
## v1.0.0 - 2023-02-05
### Commits
- Initial implementation, tests, readme [`650713e`](https://github.com/es-shims/iterator-helpers/commit/650713eecc9d4dab28d5ba3dc5afcbdb8ff99b5a)
- Initial commit [`2379dfd`](https://github.com/es-shims/iterator-helpers/commit/2379dfdad70f64efb31e342a4a7779b1140b2481)
- npm init [`f77411a`](https://github.com/es-shims/iterator-helpers/commit/f77411a443f1a103dbb92a69210228d4fc1e6d04)
- Only apps should have lockfiles [`313dcf5`](https://github.com/es-shims/iterator-helpers/commit/313dcf5211e99569ad275885728b5ac7af30f4ec)

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,112 @@
'use strict';
var $TypeError = require('es-errors/type');
var AdvanceStringIndex = require('es-abstract/2024/AdvanceStringIndex');
var Call = require('es-abstract/2024/Call');
var CompletionRecord = require('es-abstract/2024/CompletionRecord');
var CreateIteratorFromClosure = require('../aos/CreateIteratorFromClosure');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var GetMethod = require('es-abstract/2024/GetMethod');
var IsArray = require('es-abstract/2024/IsArray');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var Type = require('es-abstract/2024/Type');
var forEach = require('es-abstract/helpers/forEach');
var getIteratorMethod = require('es-abstract/helpers/getIteratorMethod');
var iterHelperProto = require('../IteratorHelperPrototype');
var SLOT = require('internal-slot');
module.exports = function concat() {
if (this instanceof concat) {
throw new $TypeError('`Iterator.concat` is not a constructor');
}
var iterables = []; // step 1
forEach(arguments, function (item) { // step 2
if (Type(item) !== 'Object') {
throw new $TypeError('`Iterator.concat` requires all arguments to be objects'); // step 2.1
}
// var method = GetMethod(item, Symbol.iterator); // step 2.2
var method = getIteratorMethod(
{
AdvanceStringIndex: AdvanceStringIndex,
GetMethod: GetMethod,
IsArray: IsArray
},
item
);
if (typeof method === 'undefined') {
throw new $TypeError('`Iterator.concat` requires all arguments to be iterable'); // step 2.3
}
iterables[iterables.length] = { '[[OpenMethod]]': method, '[[Iterable]]': item }; // step 2.4
});
var sentinel = {};
var innerIterator = sentinel;
var closeIfAbrupt = function (abruptCompletion) {
if (!(abruptCompletion instanceof CompletionRecord)) {
throw new $TypeError('`abruptCompletion` must be a Completion Record');
}
if (innerIterator !== sentinel) {
IteratorClose(
innerIterator,
abruptCompletion
);
}
};
var index = 0;
var closure = function () { // step 3
if (index < iterables.length) {
// forEach(iterables, function (iterable) { // step 3.a
var iteratorRecord;
if (innerIterator === sentinel) {
var iterable = iterables[index];
var iter = Call(iterable['[[OpenMethod]]'], iterable['[[Iterable]]']); // step 3.a.i
if (Type(iter) !== 'Object') {
closeIfAbrupt(ThrowCompletion(new $TypeError('???'))); // step 3.a.ii
}
iteratorRecord = GetIteratorDirect(iter); // step 3.a.iii
innerIterator = iteratorRecord;
} else {
iteratorRecord = innerIterator;
}
// var innerAlive = true; // step 3.a.iv
// while (innerAlive) { // step 3.a.v
if (innerIterator !== sentinel) {
// step 3.a.v.3.a
var innerValue;
try {
innerValue = IteratorStepValue(iteratorRecord); // step 5.b.ix.4.a
} catch (e) {
// innerAlive = false;
innerIterator = sentinel;
index += 1;
closeIfAbrupt(ThrowCompletion(e)); // step 3.a.v.3.b
}
if (iteratorRecord['[[Done]]']) {
// innerAlive = false;
innerIterator = sentinel;
index += 1;
return closure();
}
return innerValue; // // step 3.a.v.3.a
}
// });
}
// return ReturnCompletion(undefined); // step 3.b
return sentinel;
};
SLOT.set(closure, '[[Sentinel]]', sentinel); // for the userland implementation
SLOT.set(closure, '[[CloseIfAbrupt]]', closeIfAbrupt); // for the userland implementation
return CreateIteratorFromClosure(closure, 'Iterator Helper', iterHelperProto, []); // step 4
};

View File

@@ -0,0 +1,18 @@
'use strict';
var callBind = require('call-bind');
var define = require('define-properties');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var bound = callBind(getPolyfill(), null);
define(bound, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = bound;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
var $Iterator = require('../Iterator');
module.exports = function getPolyfill() {
return typeof $Iterator.concat === 'function' ? $Iterator.concat : implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var getPolyfill = require('./polyfill');
var define = require('define-properties');
var getIteratorPolyfill = require('../Iterator/polyfill');
module.exports = function shimIteratorConcat() {
var $Iterator = getIteratorPolyfill();
var polyfill = getPolyfill();
define(
$Iterator,
{ concat: polyfill },
{ concat: function () { return $Iterator.concat !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,32 @@
'use strict';
var $TypeError = require('es-errors/type');
var GetIteratorFlattenable = require('../aos/GetIteratorFlattenable');
var OrdinaryHasInstance = require('es-abstract/2024/OrdinaryHasInstance');
var OrdinaryObjectCreate = require('es-abstract/2024/OrdinaryObjectCreate');
var $Iterator = require('../Iterator/polyfill')();
var $WrapForValidIteratorPrototype = require('../WrapForValidIteratorPrototype');
var SLOT = require('internal-slot');
module.exports = function from(O) {
if (this instanceof from) {
throw new $TypeError('`Iterator.from` is not a constructor');
}
var iteratorRecord = GetIteratorFlattenable(O, 'iterate-strings'); // step 1
var hasInstance = OrdinaryHasInstance($Iterator, iteratorRecord['[[Iterator]]']); // step 2
if (hasInstance) { // step 3
return iteratorRecord['[[Iterator]]']; // step 3.a
}
var wrapper = OrdinaryObjectCreate($WrapForValidIteratorPrototype); // , ['[[Iterated]]']); // step 4
SLOT.set(wrapper, '[[Iterated]]', iteratorRecord); // step 5
return wrapper; // step 6
};

View File

@@ -0,0 +1,18 @@
'use strict';
var callBind = require('call-bind');
var define = require('define-properties');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var bound = callBind(getPolyfill(), null);
define(bound, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = bound;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
var $Iterator = require('../Iterator');
module.exports = function getPolyfill() {
return typeof $Iterator.from === 'function' ? $Iterator.from : implementation;
};

18
node_modules/es-iterator-helpers/Iterator.from/shim.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var getPolyfill = require('./polyfill');
var define = require('define-properties');
var getIteratorPolyfill = require('../Iterator/polyfill');
module.exports = function shimIteratorFrom() {
var $Iterator = getIteratorPolyfill();
var polyfill = getPolyfill();
define(
$Iterator,
{ from: polyfill },
{ from: function () { return $Iterator.from !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,5 @@
'use strict';
var $Iterator = require('../Iterator/polyfill')();
module.exports = $Iterator;

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var bind = require('function-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = bind.call(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,7 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return implementation;
};

View File

@@ -0,0 +1,20 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
var $Iterator = require('./implementation');
module.exports = function shimIteratorPrototypeCtor() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ constructor: $Iterator },
{ constructor: function () { return $Iterator.constructor !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,93 @@
'use strict';
var $RangeError = require('es-errors/range');
var $TypeError = require('es-errors/type');
var CompletionRecord = require('es-abstract/2024/CompletionRecord');
var CreateIteratorFromClosure = require('../aos/CreateIteratorFromClosure');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStep = require('es-abstract/2024/IteratorStep');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var ToIntegerOrInfinity = require('es-abstract/2024/ToIntegerOrInfinity');
var ToNumber = require('es-abstract/2024/ToNumber');
var Type = require('es-abstract/2024/Type');
var iterHelperProto = require('../IteratorHelperPrototype');
var isNaN = require('es-abstract/helpers/isNaN');
var SLOT = require('internal-slot');
module.exports = function drop(limit) {
if (this instanceof drop) {
throw new $TypeError('`drop` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
var numLimit = ToNumber(limit); // step 2
if (isNaN(numLimit)) {
throw new $RangeError('`limit` must be a non-NaN number'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var integerLimit = ToIntegerOrInfinity(numLimit); // step 4
if (integerLimit < 0) {
throw new $RangeError('`limit` must be a >= 0'); // step 5
}
var closeIfAbrupt = function (abruptCompletion) {
if (!(abruptCompletion instanceof CompletionRecord)) {
throw new $TypeError('`abruptCompletion` must be a Completion Record');
}
IteratorClose(
iterated,
abruptCompletion
);
};
var sentinel = {};
var remaining = integerLimit; // step 6.a
var closure = function () { // step 6
var next;
while (remaining > 0) { // step 6.b
if (remaining !== Infinity) { // step 6.b.i
remaining -= 1; // step 6.b.i.1
}
next = IteratorStep(iterated); // step 6.b.ii
if (!next) {
// return void undefined; // step 6.b.iii
return sentinel;
}
}
// while (true) { // step 6.c
try {
var value = IteratorStepValue(iterated); // step 6.b.i
if (iterated['[[Done]]']) {
return sentinel; // step 6.b.ii
}
return value;
} catch (e) {
// close iterator // step 6.c.icv
closeIfAbrupt(ThrowCompletion(e));
throw e;
}
// }
// return void undefined;
};
SLOT.set(closure, '[[Sentinel]]', sentinel); // for the userland implementation
SLOT.set(closure, '[[CloseIfAbrupt]]', closeIfAbrupt); // for the userland implementation
var result = CreateIteratorFromClosure(closure, 'Iterator Helper', iterHelperProto, ['[[UnderlyingIterator]]']); // step 4
SLOT.set(result, '[[UnderlyingIterator]]', iterated); // step 5
return result; // step 6
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,15 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
if (typeof Iterator === 'function' && typeof Iterator.prototype.drop === 'function') {
try {
// https://issues.chromium.org/issues/336839115
Iterator.prototype.drop.call({ next: null }, 0).next();
} catch (e) {
return Iterator.prototype.drop;
}
}
return implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeDrop() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ drop: polyfill },
{ drop: function () { return $IteratorPrototype.drop !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,58 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IsCallable = require('es-abstract/2024/IsCallable');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var NormalCompletion = require('es-abstract/2024/NormalCompletion');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var ToBoolean = require('es-abstract/2024/ToBoolean');
var Type = require('es-abstract/2024/Type');
module.exports = function every(predicate) {
if (this instanceof every) {
throw new $TypeError('`every` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
if (!IsCallable(predicate)) {
throw new $TypeError('`predicate` must be a function'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var counter = 0; // step 5
// eslint-disable-next-line no-constant-condition
while (true) { // step 6
var value = IteratorStepValue(iterated); // step 6.a
if (iterated['[[Done]]']) {
return true; // step 6.b
}
var result;
try {
result = Call(predicate, void undefined, [value, counter]); // step 6.c
} catch (e) {
// close iterator // step 6.d
IteratorClose(
iterated,
ThrowCompletion(e)
);
} finally {
counter += 1; // step 6.f
}
if (!ToBoolean(result)) {
return IteratorClose(
iterated,
NormalCompletion(false)
); // step 6.e
}
}
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Iterator === 'function' && typeof Iterator.prototype.every === 'function'
? Iterator.prototype.every
: implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeEvery() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ every: polyfill },
{ every: function () { return $IteratorPrototype.every !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,80 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var CompletionRecord = require('es-abstract/2024/CompletionRecord');
var CreateIteratorFromClosure = require('../aos/CreateIteratorFromClosure');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IsCallable = require('es-abstract/2024/IsCallable');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var ToBoolean = require('es-abstract/2024/ToBoolean');
var Type = require('es-abstract/2024/Type');
var iterHelperProto = require('../IteratorHelperPrototype');
var SLOT = require('internal-slot');
module.exports = function filter(predicate) {
if (this instanceof filter) {
throw new $TypeError('`filter` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
if (!IsCallable(predicate)) {
throw new $TypeError('`predicate` must be a function'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var closeIfAbrupt = function (abruptCompletion) {
if (!(abruptCompletion instanceof CompletionRecord)) {
throw new $TypeError('`abruptCompletion` must be a Completion Record');
}
IteratorClose(
iterated,
abruptCompletion
);
};
var sentinel = {};
var counter = 0; // step 6.a
var closure = function () {
// eslint-disable-next-line no-constant-condition
while (true) { // step 6.b
var value = IteratorStepValue(iterated); // step 6.b.i
if (iterated['[[Done]]']) {
return sentinel; // step 6.b.ii
}
var selected;
try {
selected = Call(predicate, void undefined, [value, counter]); // step 6.b.iv
// yield mapped // step 6.b.vi
if (ToBoolean(selected)) {
return value;
}
} catch (e) {
// close iterator // step 6.b.v, 6.b.vii
closeIfAbrupt(ThrowCompletion(e));
throw e;
} finally {
counter += 1; // step 6.b.viii
}
}
};
SLOT.set(closure, '[[Sentinel]]', sentinel); // for the userland implementation
SLOT.set(closure, '[[CloseIfAbrupt]]', closeIfAbrupt); // for the userland implementation
var result = CreateIteratorFromClosure(closure, 'Iterator Helper', iterHelperProto, ['[[UnderlyingIterator]]']); // step 7
SLOT.set(result, '[[UnderlyingIterator]]', iterated); // step 8
return result; // step 9
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,15 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
if (typeof Iterator === 'function' && typeof Iterator.prototype.filter === 'function') {
try {
// https://issues.chromium.org/issues/336839115
Iterator.prototype.filter.call({ next: null }, function () {}).next();
} catch (e) {
return Iterator.prototype.filter;
}
}
return implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeFilter() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ filter: polyfill },
{ filter: function () { return $IteratorPrototype.filter !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,59 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IsCallable = require('es-abstract/2024/IsCallable');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var NormalCompletion = require('es-abstract/2024/NormalCompletion');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var ToBoolean = require('es-abstract/2024/ToBoolean');
var Type = require('es-abstract/2024/Type');
module.exports = function find(predicate) {
if (this instanceof find) {
throw new $TypeError('`find` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
if (!IsCallable(predicate)) {
throw new $TypeError('`predicate` must be a function'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var counter = 0; // step 5
// eslint-disable-next-line no-constant-condition
while (true) { // step 6
var value = IteratorStepValue(iterated); // step 6.a
if (iterated['[[Done]]']) {
return void undefined; // step 6.b
}
var result;
try {
result = Call(predicate, void undefined, [value, counter]); // step 6.c
} catch (e) {
// close iterator // step 6.d
IteratorClose(
iterated,
ThrowCompletion(e)
);
} finally {
counter += 1; // step 6.f
}
if (ToBoolean(result)) {
return IteratorClose(
iterated,
NormalCompletion(value)
); // step 6.e
}
}
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Iterator === 'function' && typeof Iterator.prototype.find === 'function'
? Iterator.prototype.find
: implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeFind() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ find: polyfill },
{ find: function () { return $IteratorPrototype.find !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,118 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var CompletionRecord = require('es-abstract/2024/CompletionRecord');
var CreateIteratorFromClosure = require('../aos/CreateIteratorFromClosure');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var GetIteratorFlattenable = require('../aos/GetIteratorFlattenable');
var IsCallable = require('es-abstract/2024/IsCallable');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var Type = require('es-abstract/2024/Type');
var iterHelperProto = require('../IteratorHelperPrototype');
var SLOT = require('internal-slot');
module.exports = function flatMap(mapper) {
if (this instanceof flatMap) {
throw new $TypeError('`flatMap` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
if (!IsCallable(mapper)) {
throw new $TypeError('`mapper` must be a function'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var sentinel = { sentinel: true };
var innerIterator = sentinel;
var closeIfAbrupt = function (abruptCompletion) {
if (!(abruptCompletion instanceof CompletionRecord)) {
throw new $TypeError('`abruptCompletion` must be a Completion Record');
}
try {
if (innerIterator !== sentinel) {
IteratorClose(
innerIterator,
abruptCompletion
);
}
} finally {
innerIterator = sentinel;
IteratorClose(
iterated,
abruptCompletion
);
}
};
var counter = 0; // step 5.a
var innerAlive = false;
var closure = function () {
// while (true) { // step 5.b
if (innerIterator === sentinel) {
var value = IteratorStepValue(iterated); // step 5.b.i
if (iterated['[[Done]]']) {
innerAlive = false;
innerIterator = sentinel;
// return void undefined; // step 5.b.ii
return sentinel;
}
}
if (innerIterator === sentinel) {
innerAlive = true; // step 5.b.viii
try {
var mapped = Call(mapper, void undefined, [value, counter]); // step 5.b.iv
// yield mapped // step 5.b.vi
innerIterator = GetIteratorFlattenable(mapped, 'reject-strings'); // step 5.b.vi
} catch (e) {
innerAlive = false;
innerIterator = sentinel;
closeIfAbrupt(ThrowCompletion(e)); // steps 5.b.v, 5.b.vii
} finally {
counter += 1; // step 5.b.x
}
}
// while (innerAlive) { // step 5.b.ix
if (innerAlive) {
// step 5.b.ix.4
var innerValue;
try {
innerValue = IteratorStepValue(innerIterator); // step 5.b.ix.4.a
} catch (e) {
innerAlive = false;
innerIterator = sentinel;
closeIfAbrupt(ThrowCompletion(e)); // step 5.b.ix.4.b
}
if (innerIterator['[[Done]]']) {
innerAlive = false;
innerIterator = sentinel;
return closure();
}
return innerValue; // step 5.b.ix.4.c
}
// }
// return void undefined;
return sentinel;
};
SLOT.set(closure, '[[Sentinel]]', sentinel); // for the userland implementation
SLOT.set(closure, '[[CloseIfAbrupt]]', closeIfAbrupt); // for the userland implementation
var result = CreateIteratorFromClosure(closure, 'Iterator Helper', iterHelperProto, ['[[UnderlyingIterator]]']); // step 7
SLOT.set(result, '[[UnderlyingIterator]]', iterated); // step 8
return result; // step 9
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,15 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
if (typeof Iterator === 'function' && typeof Iterator.prototype.flatMap === 'function') {
try {
// https://issues.chromium.org/issues/336839115
Iterator.prototype.flatMap.call({ next: null }, function () {}).next();
} catch (e) {
return Iterator.prototype.flatMap;
}
}
return implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeFlatMap() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ flatMap: polyfill },
{ flatMap: function () { return $IteratorPrototype.flatMap !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,49 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IsCallable = require('es-abstract/2024/IsCallable');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var Type = require('es-abstract/2024/Type');
module.exports = function forEach(fn) {
if (this instanceof forEach) {
throw new $TypeError('`forEach` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
if (!IsCallable(fn)) {
throw new $TypeError('`fn` must be a function'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var counter = 0; // step 5
// eslint-disable-next-line no-constant-condition
while (true) { // step 6
var value = IteratorStepValue(iterated); // step 6.a
if (iterated['[[Done]]']) {
return void undefined; // step 6.b
}
try {
Call(fn, void undefined, [value, counter]); // step 6.c
} catch (e) {
IteratorClose(
iterated,
ThrowCompletion(e)
); // steps 6.d
throw e;
} finally {
counter += 1; // step 6.e
}
}
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Iterator === 'function' && typeof Iterator.prototype.forEach === 'function'
? Iterator.prototype.forEach
: implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeForEach() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ forEach: polyfill },
{ forEach: function () { return $IteratorPrototype.forEach !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,76 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var CompletionRecord = require('es-abstract/2024/CompletionRecord');
var CreateIteratorFromClosure = require('../aos/CreateIteratorFromClosure');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IsCallable = require('es-abstract/2024/IsCallable');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var Type = require('es-abstract/2024/Type');
var iterHelperProto = require('../IteratorHelperPrototype');
var SLOT = require('internal-slot');
module.exports = function map(mapper) {
if (this instanceof map) {
throw new $TypeError('`map` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
if (!IsCallable(mapper)) {
throw new $TypeError('`mapper` must be a function'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var closeIfAbrupt = function (abruptCompletion) {
if (!(abruptCompletion instanceof CompletionRecord)) {
throw new $TypeError('`abruptCompletion` must be a Completion Record');
}
IteratorClose(
iterated,
abruptCompletion
);
};
var sentinel = {};
var counter = 0; // step 6.a
var closure = function () {
// while (true) { // step 6.b
var value = IteratorStepValue(iterated); // step 6.b.i
if (iterated['[[Done]]']) {
return sentinel; // step 6.b.ii
}
var mapped;
try {
mapped = Call(mapper, void undefined, [value, counter]); // step 6.b.iii
// yield mapped // step 6.b.vi
return mapped;
} catch (e) {
// close iterator // step 6.b.v, 6.b.vii
closeIfAbrupt(ThrowCompletion(e));
throw e;
} finally {
counter += 1; // step 6.b.viii
}
// }
};
SLOT.set(closure, '[[Sentinel]]', sentinel); // for the userland implementation
SLOT.set(closure, '[[CloseIfAbrupt]]', closeIfAbrupt); // for the userland implementation
var result = CreateIteratorFromClosure(closure, 'Iterator Helper', iterHelperProto, ['[[UnderlyingIterator]]']); // step 7
SLOT.set(result, '[[UnderlyingIterator]]', iterated); // step 8
return result; // step 9
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,15 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
if (typeof Iterator === 'function' && typeof Iterator.prototype.map === 'function') {
try {
// https://issues.chromium.org/issues/336839115
Iterator.prototype.map.call({ next: null }, function () {}).next();
} catch (e) {
return Iterator.prototype.map;
}
}
return implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeMap() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ map: polyfill },
{ map: function () { return $IteratorPrototype.map !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,60 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IsCallable = require('es-abstract/2024/IsCallable');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var Type = require('es-abstract/2024/Type');
module.exports = function reduce(reducer) {
if (this instanceof reduce) {
throw new $TypeError('`reduce` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
if (!IsCallable(reducer)) {
throw new $TypeError('`reducer` must be a function'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var accumulator;
var counter;
if (arguments.length < 2) { // step 6
accumulator = IteratorStepValue(iterated); // step 6.a
if (iterated['[[Done]]']) {
throw new $TypeError('Reduce of empty iterator with no initial value');
}
counter = 1;
} else { // step 7
accumulator = arguments[1]; // step 7.a
counter = 0;
}
// eslint-disable-next-line no-constant-condition
while (true) { // step 8
var value = IteratorStepValue(iterated); // step 8.a
if (iterated['[[Done]]']) {
return accumulator; // step 8.b
}
try {
var result = Call(reducer, void undefined, [accumulator, value, counter]); // step 8.d
accumulator = result; // step 8.f
} catch (e) {
// close iterator // step 8.e
IteratorClose(
iterated,
ThrowCompletion(e)
);
}
counter += 1; // step 8.g
}
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Iterator === 'function' && typeof Iterator.prototype.reduce === 'function'
? Iterator.prototype.reduce
: implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeReduce() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ reduce: polyfill },
{ reduce: function () { return $IteratorPrototype.reduce !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,58 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IsCallable = require('es-abstract/2024/IsCallable');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var NormalCompletion = require('es-abstract/2024/NormalCompletion');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var ToBoolean = require('es-abstract/2024/ToBoolean');
var Type = require('es-abstract/2024/Type');
module.exports = function some(predicate) {
if (this instanceof some) {
throw new $TypeError('`some` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
if (!IsCallable(predicate)) {
throw new $TypeError('`predicate` must be a function'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var counter = 0; // step 5
// eslint-disable-next-line no-constant-condition
while (true) { // step 6
var value = IteratorStepValue(iterated); // step 6.a
if (iterated['[[Done]]']) {
return false; // step 6.b
}
var result;
try {
result = Call(predicate, void undefined, [value, counter]); // step 6.c
} catch (e) {
// close iterator // step 6.d
IteratorClose(
iterated,
ThrowCompletion(e)
);
} finally {
counter += 1; // step 6.f
}
if (ToBoolean(result)) {
return IteratorClose(
iterated,
NormalCompletion(true)
); // step 6.e
}
}
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Iterator === 'function' && typeof Iterator.prototype.some === 'function'
? Iterator.prototype.some
: implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeSome() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ some: polyfill },
{ some: function () { return $IteratorPrototype.some !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,84 @@
'use strict';
var $RangeError = require('es-errors/range');
var $TypeError = require('es-errors/type');
var CompletionRecord = require('es-abstract/2024/CompletionRecord');
var CreateIteratorFromClosure = require('../aos/CreateIteratorFromClosure');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var NormalCompletion = require('es-abstract/2024/NormalCompletion');
var ToIntegerOrInfinity = require('es-abstract/2024/ToIntegerOrInfinity');
var ToNumber = require('es-abstract/2024/ToNumber');
var Type = require('es-abstract/2024/Type');
var iterHelperProto = require('../IteratorHelperPrototype');
var isNaN = require('es-abstract/helpers/isNaN');
var SLOT = require('internal-slot');
module.exports = function take(limit) {
if (this instanceof take) {
throw new $TypeError('`take` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
var numLimit = ToNumber(limit); // step 2
if (isNaN(numLimit)) {
throw new $RangeError('`limit` must be a non-NaN number'); // step 3
}
var iterated = GetIteratorDirect(O); // step 4
var integerLimit = ToIntegerOrInfinity(numLimit); // step 7
if (integerLimit < 0) {
throw new $RangeError('`limit` must be a >= 0'); // step 8
}
var closeIfAbrupt = function (abruptCompletion) {
if (!(abruptCompletion instanceof CompletionRecord)) {
throw new $TypeError('`abruptCompletion` must be a Completion Record');
}
IteratorClose(
iterated,
abruptCompletion
);
};
var sentinel = {};
var remaining = integerLimit; // step 9.a
var closure = function () { // step 9
// while (true) { // step 9.b
if (remaining === 0) { // step 9.b.i
return IteratorClose( // step 9.b.i.1
iterated,
NormalCompletion(sentinel)
);
}
if (remaining !== Infinity) { // step 9.b.ii
remaining -= 1; // step 9.b.ii.1
}
var value = IteratorStepValue(iterated); // step 6.b.i
if (iterated['[[Done]]']) {
return sentinel; // step 6.b.ii
}
return value; // step 9.b.iv
// }
};
SLOT.set(closure, '[[Sentinel]]', sentinel); // for the userland implementation
SLOT.set(closure, '[[CloseIfAbrupt]]', closeIfAbrupt); // for the userland implementation
var result = CreateIteratorFromClosure(closure, 'Iterator Helper', iterHelperProto, ['[[UnderlyingIterator]]']); // step 7
SLOT.set(result, '[[UnderlyingIterator]]', iterated); // step 8
return result; // step 9
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Iterator === 'function' && typeof Iterator.prototype.take === 'function'
? Iterator.prototype.take
: implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeTake() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ take: polyfill },
{ take: function () { return $IteratorPrototype.take !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,36 @@
'use strict';
var $TypeError = require('es-errors/type');
var GetIteratorDirect = require('../aos/GetIteratorDirect');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var Type = require('es-abstract/2024/Type');
var callBound = require('call-bind/callBound');
var $push = callBound('Array.prototype.push');
module.exports = function toArray() {
if (this instanceof toArray) {
throw new $TypeError('`toArray` is not a constructor');
}
var O = this; // step 1
if (Type(O) !== 'Object') {
throw new $TypeError('`this` value must be an Object'); // step 2
}
var iterated = GetIteratorDirect(O); // step 3
var items = []; // step 4
// eslint-disable-next-line no-constant-condition
while (true) { // step 5
var value = IteratorStepValue(iterated); // step 5.a
if (iterated['[[Done]]']) {
return items; // step 5.b
}
$push(items, value); // step 5.d
}
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Iterator === 'function' && typeof Iterator.prototype.toArray === 'function'
? Iterator.prototype.toArray
: implementation;
};

View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var $IteratorPrototype = require('../Iterator.prototype/implementation');
module.exports = function shimIteratorPrototypeToArray() {
var polyfill = getPolyfill();
define(
$IteratorPrototype,
{ toArray: polyfill },
{ toArray: function () { return $IteratorPrototype.toArray !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,3 @@
'use strict';
module.exports = require('iterator.prototype');

View File

@@ -0,0 +1,12 @@
'use strict';
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
module.exports = {
__proto__: getPolyfill(),
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
};

View File

@@ -0,0 +1,7 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return implementation;
};

View File

@@ -0,0 +1,20 @@
'use strict';
var getPolyfill = require('./polyfill');
var define = require('define-properties');
var getIteratorPolyfill = require('../Iterator/polyfill');
module.exports = function shimIteratorFrom() {
var $Iterator = getIteratorPolyfill();
var polyfill = getPolyfill();
define(
$Iterator,
{ prototype: polyfill },
{ prototype: function () { return $Iterator.prototype !== polyfill; } }
);
// TODO: install Symbol.toStringTag if needed, once https://bugs.chromium.org/p/chromium/issues/detail?id=1477372 is fixed?
return polyfill;
};

3
node_modules/es-iterator-helpers/Iterator/auto.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,29 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var hasPropertyDescriptors = require('has-property-descriptors')();
var $TypeError = require('es-errors/type');
var $defineProperty = hasPropertyDescriptors && GetIntrinsic('%Object.defineProperty%', true);
var iterProto = require('iterator.prototype');
var callBound = require('call-bind/callBound');
var $isPrototypeOf = callBound('Object.prototype.isPrototypeOf');
var $Iterator = typeof Iterator === 'function' ? Iterator : function Iterator() {
if (
!(this instanceof Iterator)
|| this.constructor === Iterator
|| !$isPrototypeOf(Iterator, this.constructor)
) {
throw new $TypeError('`Iterator` can not be called or constructed directly');
}
};
if ($Iterator.prototype !== iterProto) {
$Iterator.prototype = iterProto;
}
$defineProperty($Iterator, 'prototype', { writable: false });
module.exports = $Iterator;

18
node_modules/es-iterator-helpers/Iterator/index.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var polyfill = callBind(getPolyfill());
define(polyfill, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = polyfill;

View File

@@ -0,0 +1,8 @@
'use strict';
var globalThis = require('globalthis')();
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof globalThis.Iterator === 'function' ? globalThis.Iterator : implementation;
};

18
node_modules/es-iterator-helpers/Iterator/shim.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var globalThis = require('globalthis')();
var getPolyfill = require('./polyfill');
module.exports = function shimIterator() {
var polyfill = getPolyfill();
define(
globalThis,
{ Iterator: polyfill },
{ Iterator: function () { return Iterator !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,55 @@
'use strict';
var setToStringTag = require('es-set-tostringtag');
var hasProto = require('has-proto')();
var iterProto = require('../Iterator.prototype/implementation');
var SLOT = require('internal-slot');
var CompletionRecord = require('es-abstract/2024/CompletionRecord');
var CreateIterResultObject = require('es-abstract/2024/CreateIterResultObject');
var GeneratorResume = require('../aos/GeneratorResume');
var GeneratorResumeAbrupt = require('../aos/GeneratorResumeAbrupt');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var NormalCompletion = require('es-abstract/2024/NormalCompletion');
var implementation;
if (hasProto) {
implementation = {
__proto__: iterProto,
next: function next() {
return GeneratorResume(this, void undefined, 'Iterator Helper');
},
'return': function () {
var O = this; // step 1
SLOT.assert(O, '[[UnderlyingIterator]]'); // step 2
SLOT.assert(O, '[[GeneratorState]]'); // step 3
if (SLOT.get(O, '[[GeneratorState]]') === 'suspendedStart') { // step 4
SLOT.set(O, '[[GeneratorState]]', 'completed'); // step 4.a
IteratorClose(SLOT.get(O, '[[UnderlyingIterator]]'), NormalCompletion('unused')); // step 4.c
return CreateIterResultObject(void undefined, true); // step 4.d
}
var C = new CompletionRecord('return', void undefined); // step 5
return GeneratorResumeAbrupt(O, C, 'Iterator Helper'); // step 6
}
};
setToStringTag(implementation, 'Iterator Helper');
} else {
var IteratorHelper = function IteratorHelper() {};
IteratorHelper.prototype = iterProto;
implementation = new IteratorHelper();
delete implementation.constructor;
implementation.next = function next() {
return GeneratorResume(this, void undefined, 'Iterator Helper');
};
implementation['return'] = function () {
var C = new CompletionRecord('return', void undefined); // step 1
return GeneratorResumeAbrupt(this, C, 'Iterator Helper');
};
}
module.exports = implementation;

21
node_modules/es-iterator-helpers/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 ECMAScript Shims
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

108
node_modules/es-iterator-helpers/README.md generated vendored Normal file
View File

@@ -0,0 +1,108 @@
# es-iterator-helpers <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
An ESnext spec-compliant sync iterator helpers shim/polyfill/replacement that works as far down as ES3.
This package implements the [es-shim API](https://github.com/es-shims/api) “multi” interface. It works in an ES3-supported environment and complies with the [iterator helpers spec](https://tc39.es/proposal-iterator-helpers/) and the [iterator sequencing spec](https://tc39.es/proposal-iterator-sequencing/).
Because the `Iterator.prototype` methods depend on a receiver (the `this` value), the main export in each subdirectory takes the iterator to operate on as the first argument.
The main export of the package itself is simply an array of the available directory names. Its sole intended use is for build tooling and testing.
## Supported things
- [`Iterator` constructor](https://tc39.es/proposal-iterator-helpers/#sec-iterator-constructor)
- [`Iterator.prototype`](https://tc39.es/proposal-iterator-helpers/#sec-iterator.prototype)
- [`Iterator.concat`](https://tc39.es/proposal-iterator-sequencing/)
- [`Iterator.from`](https://tc39.es/proposal-iterator-helpers/#sec-iterator.from)
- [`Iterator.prototype.constructor`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.constructor)
- [`Iterator.prototype.drop`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.drop)
- [`Iterator.prototype.every`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.every)
- [`Iterator.prototype.filter`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.filter)
- [`Iterator.prototype.find`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.find)
- [`Iterator.prototype.flatMap`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.flatmap)
- [`Iterator.prototype.forEach`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.foreach)
- [`Iterator.prototype.map`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.map)
- [`Iterator.prototype.reduce`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.reduce)
- [`Iterator.prototype.some`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.some)
- [`Iterator.prototype.take`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.take)
- [`Iterator.prototype.toArray`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.toarray)
## Environments where this is needed
- node v22, Chrome >= v122: has a [bug](https://issues.chromium.org/issues/336839115)
- node < v22, Chrome < v122, Safari <= v17.1, Firefox <= v125: not implemented
- all environments lack Iterator.concat
## Getting started
```sh
npm install --save es-iterator-helpers
```
## Usage/Examples
Using explicit imports:
```js
const map = require('es-iterator-helpers/Iterator.prototype.map');
const toArray = require('es-iterator-helpers/Iterator.prototype.toArray');
const assert = require('assert');
const iterator = [1, 2, 3].values();
const mapped = map(iterator, (x) => x + 10);
assert.deepEqual(
mapped.next(),
{
done: false,
value: 11,
}
);
assert.deepEqual(
toArray(mapped),
[12, 13]
);
```
Shim using `require`:
```js
require('es-iterator-helpers/auto'); // shim all of the methods
require('es-iterator-helpers/Iterator.prototype.map/auto'); // shim the “map” method
```
Shim using `import` syntax:
[](#preventEval)
```js
import 'es-iterator-helpers/auto'; // shim all of the methods
import 'es-iterator-helpers/Iterator.prototype.map/auto'; // shim the “map” method
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/es-iterator-helpers
[npm-version-svg]: https://versionbadg.es/es-shims/iterator-helpers.svg
[deps-svg]: https://david-dm.org/es-shims/iterator-helpers.svg
[deps-url]: https://david-dm.org/es-shims/iterator-helpers
[dev-deps-svg]: https://david-dm.org/es-shims/iterator-helpers/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/iterator-helpers#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/es-iterator-helpers.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/es-iterator-helpers.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/es-iterator-helpers.svg
[downloads-url]: https://npm-stat.com/charts.html?package=es-iterator-helpers
[codecov-image]: https://codecov.io/gh/es-shims/iterator-helpers/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/iterator-helpers/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/iterator-helpers
[actions-url]: https://github.com/es-shims/iterator-helpers/actions

View File

@@ -0,0 +1,46 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var CreateIterResultObject = require('es-abstract/2024/CreateIterResultObject');
var GetMethod = require('es-abstract/2024/GetMethod');
var Type = require('es-abstract/2024/Type');
var SLOT = require('internal-slot');
var iterProto = require('../Iterator.prototype/implementation');
// https://tc39.es/proposal-iterator-helpers/#sec-wrapforvaliditeratorprototype-object
module.exports = /* GetIntrinsic('%WrapForValidIteratorPrototype%', true) || */ {
__proto__: iterProto,
next: function next() {
var O = this; // step 1
// RequireInternalSlot(O, [[Iterated]]); // step 2
SLOT.assert(O, '[[Iterated]]');
var iteratorRecord = SLOT.get(O, '[[Iterated]]'); // step 3
return Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']); // step 4
},
'return': function () {
var O = this; // step 1
// RequireInternalSlot(O, [[Iterated]]); // step 2
SLOT.assert(O, '[[Iterated]]');
var iterator = SLOT.get(O, '[[Iterated]]')['[[Iterator]]']; // step 3
if (Type(iterator) !== 'Object') {
throw new $TypeError('iterator must be an Object'); // step 4
}
var returnMethod = GetMethod(iterator, 'return'); // step 5
if (typeof returnMethod === 'undefined') { // step 6
return CreateIterResultObject(undefined, true); // step 6.a
}
return Call(returnMethod, iterator); // step 7
}
};

View File

@@ -0,0 +1,45 @@
'use strict';
var $TypeError = require('es-errors/type');
var GeneratorStart = require('./GeneratorStart');
var IsArray = require('es-abstract/2024/IsArray');
var IsCallable = require('es-abstract/2024/IsCallable');
var OrdinaryObjectCreate = require('es-abstract/2024/OrdinaryObjectCreate');
var every = require('es-abstract/helpers/every');
var SLOT = require('internal-slot');
var safeConcat = require('safe-array-concat');
var isString = function isString(slot) {
return typeof slot === 'string';
};
module.exports = function CreateIteratorFromClosure(closure, generatorBrand, proto) {
if (!IsCallable(closure)) {
throw new $TypeError('`closure` must be a function');
}
if (typeof generatorBrand !== 'string') {
throw new $TypeError('`generatorBrand` must be a string');
}
var extraSlots = arguments.length > 3 ? arguments[3] : [];
if (arguments.length > 3) {
if (!IsArray(extraSlots) || !every(extraSlots, isString)) {
throw new $TypeError('`extraSlots` must be a List of String internal slot names');
}
}
var internalSlotsList = safeConcat(extraSlots, ['[[GeneratorContext]]', '[[GeneratorBrand]]', '[[GeneratorState]]']); // step 3
var generator = OrdinaryObjectCreate(proto, internalSlotsList); // steps 4, 6
SLOT.set(generator, '[[GeneratorBrand]]', generatorBrand); // step 5
SLOT.assert(closure, '[[Sentinel]]'); // our userland slot
SLOT.set(generator, '[[Sentinel]]', SLOT.get(closure, '[[Sentinel]]')); // our userland slot
SLOT.assert(closure, '[[CloseIfAbrupt]]'); // our second userland slot
SLOT.set(generator, '[[CloseIfAbrupt]]', SLOT.get(closure, '[[CloseIfAbrupt]]')); // our second userland slot
GeneratorStart(generator, closure); // step 13
return generator; // step 15
};

View File

@@ -0,0 +1,27 @@
'use strict';
var $TypeError = require('es-errors/type');
var CreateIterResultObject = require('es-abstract/2024/CreateIterResultObject');
var GeneratorValidate = require('./GeneratorValidate');
var SLOT = require('internal-slot');
module.exports = function GeneratorResume(generator, value, generatorBrand) {
var state = GeneratorValidate(generator, generatorBrand); // step 1
if (state === 'completed') {
return CreateIterResultObject(void undefined, true); // step 2
}
if (state !== 'suspendedStart' && state !== 'suspendedYield') {
throw new $TypeError('Assertion failed: generator state is unexpected: ' + state); // step 3
}
var genContext = SLOT.get(generator, '[[GeneratorContext]]');
SLOT.set(generator, '[[GeneratorState]]', 'executing'); // step 7
var result = genContext(value); // steps 5-6, 8-10
return result;
};

View File

@@ -0,0 +1,46 @@
'use strict';
var $TypeError = require('es-errors/type');
var CompletionRecord = require('es-abstract/2024/CompletionRecord');
var CreateIterResultObject = require('es-abstract/2024/CreateIterResultObject');
var GeneratorValidate = require('./GeneratorValidate');
var NormalCompletion = require('es-abstract/2024/NormalCompletion');
var SLOT = require('internal-slot');
module.exports = function GeneratorResumeAbrupt(generator, abruptCompletion, generatorBrand) {
if (!(abruptCompletion instanceof CompletionRecord)) {
throw new $TypeError('Assertion failed: abruptCompletion must be a Completion Record');
}
var state = GeneratorValidate(generator, generatorBrand); // step 1
if (state === 'suspendedStart') { // step 2
SLOT.set(generator, '[[GeneratorState]]', 'completed'); // step 3.a
SLOT.set(generator, '[[GeneratorContext]]', null); // step 3.b
state = 'completed'; // step 3.c
}
var value = abruptCompletion.value();
if (state === 'completed') { // step 3
return CreateIterResultObject(value, true); // steps 3.a-b
}
if (state !== 'suspendedYield') {
throw new $TypeError('Assertion failed: generator state is unexpected: ' + state); // step 4
}
if (abruptCompletion.type() === 'return') {
// due to representing `GeneratorContext` as a function, we can't safely re-invoke it, so we can't support sending it a return completion
return CreateIterResultObject(SLOT.get(generator, '[[CloseIfAbrupt]]')(NormalCompletion(abruptCompletion.value())), true);
}
var genContext = SLOT.get(generator, '[[GeneratorContext]]'); // step 5
SLOT.set(generator, '[[GeneratorState]]', 'executing'); // step 8
var result = genContext(value); // steps 6-7, 8-11
return result; // step 12
};

44
node_modules/es-iterator-helpers/aos/GeneratorStart.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
'use strict';
var $TypeError = require('es-errors/type');
var CreateIterResultObject = require('es-abstract/2024/CreateIterResultObject');
var IsCallable = require('es-abstract/2024/IsCallable');
var Type = require('es-abstract/2024/Type');
var SLOT = require('internal-slot');
module.exports = function GeneratorStart(generator, closure) {
SLOT.assert(generator, '[[GeneratorState]]');
SLOT.assert(generator, '[[GeneratorContext]]');
SLOT.assert(generator, '[[GeneratorBrand]]');
SLOT.assert(generator, '[[Sentinel]]'); // our userland slot
SLOT.assert(generator, '[[CloseIfAbrupt]]'); // our second userland slot
if (!IsCallable(closure) || closure.length !== 0) {
throw new $TypeError('`closure` must be a function that takes no arguments');
}
var sentinel = SLOT.get(closure, '[[Sentinel]]');
if (Type(sentinel) !== 'Object') {
throw new $TypeError('`closure.[[Sentinel]]` must be an object');
}
SLOT.set(generator, '[[GeneratorContext]]', function () { // steps 2-5
try {
var result = closure();
if (result === sentinel) {
SLOT.set(generator, '[[GeneratorState]]', 'completed');
SLOT.set(generator, '[[GeneratorContext]]', null);
return CreateIterResultObject(void undefined, true);
}
SLOT.set(generator, '[[GeneratorState]]', 'suspendedYield');
return CreateIterResultObject(result, false);
} catch (e) {
SLOT.set(generator, '[[GeneratorState]]', 'completed');
SLOT.set(generator, '[[GeneratorContext]]', null);
throw e;
}
});
SLOT.set(generator, '[[GeneratorState]]', 'suspendedStart'); // step 6
};

View File

@@ -0,0 +1,22 @@
'use strict';
var $TypeError = require('es-errors/type');
var SLOT = require('internal-slot');
module.exports = function GeneratorValidate(generator, generatorBrand) {
SLOT.assert(generator, '[[GeneratorState]]'); // step 1
SLOT.assert(generator, '[[GeneratorBrand]]'); // step 2
var brand = SLOT.get(generator, '[[GeneratorBrand]]');
if (brand !== generatorBrand) {
throw new $TypeError('Assertion failed: generator brand is unexpected: ' + brand);
}
SLOT.assert(generator, '[[GeneratorContext]]'); // step 4
var state = SLOT.get(generator, '[[GeneratorState]]'); // step 5
if (state === 'executing') {
throw new $TypeError('generator is executing');
}
return state; // step 7
};

View File

@@ -0,0 +1,18 @@
'use strict';
var $TypeError = require('es-errors/type');
var Get = require('es-abstract/2024/Get');
var Type = require('es-abstract/2024/Type');
module.exports = function GetIteratorDirect(obj) {
if (Type(obj) !== 'Object') {
throw new $TypeError('Assertion failed: `obj` must be an Object');
}
var nextMethod = Get(obj, 'next'); // step 2
var iteratorRecord = { '[[Iterator]]': obj, '[[NextMethod]]': nextMethod, '[[Done]]': false }; // step 3
return iteratorRecord; // step 4
};

View File

@@ -0,0 +1,44 @@
'use strict';
var $TypeError = require('es-errors/type');
var AdvanceStringIndex = require('es-abstract/2024/AdvanceStringIndex');
var Call = require('es-abstract/2024/Call');
var GetIteratorDirect = require('./GetIteratorDirect');
var GetMethod = require('es-abstract/2024/GetMethod');
var IsArray = require('es-abstract/2024/IsArray');
var Type = require('es-abstract/2024/Type');
var getIteratorMethod = require('es-abstract/helpers/getIteratorMethod');
module.exports = function GetIteratorFlattenable(obj, stringHandling) {
if (Type(obj) !== 'Object') {
if (stringHandling === 'reject-strings' || typeof obj !== 'string') {
throw new $TypeError('obj must be an Object'); // step 1.a
}
}
var method = void undefined; // step 2
// method = GetMethod(obj, Symbol.iterator); // step 5.a
method = getIteratorMethod(
{
AdvanceStringIndex: AdvanceStringIndex,
GetMethod: GetMethod,
IsArray: IsArray
},
obj
);
var iterator;
if (typeof method === 'undefined') { // step 3
iterator = obj; // step 3.a
} else { // step 4
iterator = Call(method, obj); // step 4.a
}
if (Type(iterator) !== 'Object') {
throw new $TypeError('iterator must be an Object'); // step 5
}
return GetIteratorDirect(iterator); // step 6
};

3
node_modules/es-iterator-helpers/auto.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

18
node_modules/es-iterator-helpers/index.json generated vendored Normal file
View File

@@ -0,0 +1,18 @@
[
"Iterator",
"Iterator.concat",
"Iterator.from",
"Iterator.prototype",
"Iterator.prototype.constructor",
"Iterator.prototype.drop",
"Iterator.prototype.every",
"Iterator.prototype.filter",
"Iterator.prototype.find",
"Iterator.prototype.flatMap",
"Iterator.prototype.forEach",
"Iterator.prototype.map",
"Iterator.prototype.reduce",
"Iterator.prototype.some",
"Iterator.prototype.take",
"Iterator.prototype.toArray"
]

193
node_modules/es-iterator-helpers/package.json generated vendored Normal file
View File

@@ -0,0 +1,193 @@
{
"name": "es-iterator-helpers",
"version": "1.1.0",
"description": "An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3.",
"main": "index.json",
"exports": {
".": "./index.json",
"./auto": "./auto.js",
"./shim": "./shim.js",
"./Iterator": "./Iterator/index.js",
"./Iterator/auto": "./Iterator/auto.js",
"./Iterator/polyfill": "./Iterator/polyfill.js",
"./Iterator/implementation": "./Iterator/implementation.js",
"./Iterator/shim": "./Iterator/shim.js",
"./Iterator.prototype": "./Iterator.prototype/index.js",
"./Iterator.prototype/auto": "./Iterator.prototype/auto.js",
"./Iterator.prototype/polyfill": "./Iterator.prototype/polyfill.js",
"./Iterator.prototype/implementation": "./Iterator.prototype/implementation.js",
"./Iterator.prototype/shim": "./Iterator.prototype/shim.js",
"./Iterator.concat": "./Iterator.concat/index.js",
"./Iterator.concat/auto": "./Iterator.concat/auto.js",
"./Iterator.concat/polyfill": "./Iterator.concat/polyfill.js",
"./Iterator.concat/implementation": "./Iterator.concat/implementation.js",
"./Iterator.concat/shim": "./Iterator.concat/shim.js",
"./Iterator.from": "./Iterator.from/index.js",
"./Iterator.from/auto": "./Iterator.from/auto.js",
"./Iterator.from/polyfill": "./Iterator.from/polyfill.js",
"./Iterator.from/implementation": "./Iterator.from/implementation.js",
"./Iterator.from/shim": "./Iterator.from/shim.js",
"./Iterator.prototype.constructor": "./Iterator.prototype.constructor/index.js",
"./Iterator.prototype.constructor/auto": "./Iterator.prototype.constructor/auto.js",
"./Iterator.prototype.constructor/polyfill": "./Iterator.prototype.constructor/polyfill.js",
"./Iterator.prototype.constructor/implementation": "./Iterator.prototype.constructor/implementation.js",
"./Iterator.prototype.constructor/shim": "./Iterator.prototype.constructor/shim.js",
"./Iterator.prototype.map": "./Iterator.prototype.map/index.js",
"./Iterator.prototype.map/auto": "./Iterator.prototype.map/auto.js",
"./Iterator.prototype.map/polyfill": "./Iterator.prototype.map/polyfill.js",
"./Iterator.prototype.map/implementation": "./Iterator.prototype.map/implementation.js",
"./Iterator.prototype.map/shim": "./Iterator.prototype.map/shim.js",
"./Iterator.prototype.filter": "./Iterator.prototype.filter/index.js",
"./Iterator.prototype.filter/auto": "./Iterator.prototype.filter/auto.js",
"./Iterator.prototype.filter/polyfill": "./Iterator.prototype.filter/polyfill.js",
"./Iterator.prototype.filter/implementation": "./Iterator.prototype.filter/implementation.js",
"./Iterator.prototype.filter/shim": "./Iterator.prototype.filter/shim.js",
"./Iterator.prototype.take": "./Iterator.prototype.take/index.js",
"./Iterator.prototype.take/auto": "./Iterator.prototype.take/auto.js",
"./Iterator.prototype.take/polyfill": "./Iterator.prototype.take/polyfill.js",
"./Iterator.prototype.take/implementation": "./Iterator.prototype.take/implementation.js",
"./Iterator.prototype.take/shim": "./Iterator.prototype.take/shim.js",
"./Iterator.prototype.drop": "./Iterator.prototype.drop/index.js",
"./Iterator.prototype.drop/auto": "./Iterator.prototype.drop/auto.js",
"./Iterator.prototype.drop/polyfill": "./Iterator.prototype.drop/polyfill.js",
"./Iterator.prototype.drop/implementation": "./Iterator.prototype.drop/implementation.js",
"./Iterator.prototype.drop/shim": "./Iterator.prototype.drop/shim.js",
"./Iterator.prototype.flatMap": "./Iterator.prototype.flatMap/index.js",
"./Iterator.prototype.flatMap/auto": "./Iterator.prototype.flatMap/auto.js",
"./Iterator.prototype.flatMap/polyfill": "./Iterator.prototype.flatMap/polyfill.js",
"./Iterator.prototype.flatMap/implementation": "./Iterator.prototype.flatMap/implementation.js",
"./Iterator.prototype.flatMap/shim": "./Iterator.prototype.flatMap/shim.js",
"./Iterator.prototype.reduce": "./Iterator.prototype.reduce/index.js",
"./Iterator.prototype.reduce/auto": "./Iterator.prototype.reduce/auto.js",
"./Iterator.prototype.reduce/polyfill": "./Iterator.prototype.reduce/polyfill.js",
"./Iterator.prototype.reduce/implementation": "./Iterator.prototype.reduce/implementation.js",
"./Iterator.prototype.reduce/shim": "./Iterator.prototype.reduce/shim.js",
"./Iterator.prototype.toArray": "./Iterator.prototype.toArray/index.js",
"./Iterator.prototype.toArray/auto": "./Iterator.prototype.toArray/auto.js",
"./Iterator.prototype.toArray/polyfill": "./Iterator.prototype.toArray/polyfill.js",
"./Iterator.prototype.toArray/implementation": "./Iterator.prototype.toArray/implementation.js",
"./Iterator.prototype.toArray/shim": "./Iterator.prototype.toArray/shim.js",
"./Iterator.prototype.forEach": "./Iterator.prototype.forEach/index.js",
"./Iterator.prototype.forEach/auto": "./Iterator.prototype.forEach/auto.js",
"./Iterator.prototype.forEach/polyfill": "./Iterator.prototype.forEach/polyfill.js",
"./Iterator.prototype.forEach/implementation": "./Iterator.prototype.forEach/implementation.js",
"./Iterator.prototype.forEach/shim": "./Iterator.prototype.forEach/shim.js",
"./Iterator.prototype.some": "./Iterator.prototype.some/index.js",
"./Iterator.prototype.some/auto": "./Iterator.prototype.some/auto.js",
"./Iterator.prototype.some/polyfill": "./Iterator.prototype.some/polyfill.js",
"./Iterator.prototype.some/implementation": "./Iterator.prototype.some/implementation.js",
"./Iterator.prototype.some/shim": "./Iterator.prototype.some/shim.js",
"./Iterator.prototype.every": "./Iterator.prototype.every/index.js",
"./Iterator.prototype.every/auto": "./Iterator.prototype.every/auto.js",
"./Iterator.prototype.every/polyfill": "./Iterator.prototype.every/polyfill.js",
"./Iterator.prototype.every/implementation": "./Iterator.prototype.every/implementation.js",
"./Iterator.prototype.every/shim": "./Iterator.prototype.every/shim.js",
"./Iterator.prototype.find": "./Iterator.prototype.find/index.js",
"./Iterator.prototype.find/auto": "./Iterator.prototype.find/auto.js",
"./Iterator.prototype.find/polyfill": "./Iterator.prototype.find/polyfill.js",
"./Iterator.prototype.find/implementation": "./Iterator.prototype.find/implementation.js",
"./Iterator.prototype.find/shim": "./Iterator.prototype.find/shim.js",
"./package.json": "./package.json"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prelint": "es-shim-api --bound --multi --ignore-dirs=WrapForValidIteratorPrototype,IteratorHelperPrototype",
"lint": "eslint --ext=js,mjs .",
"postlint": "evalmd README.md",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "nyc tape 'test/**/*.js'",
"posttest": "npx npm@'>=10.2' audit --production",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/es-shims/iterator-helpers.git"
},
"keywords": [
"javascript",
"ecmascript",
"polyfill",
"shim",
"es-shims",
"es-shim API",
"Iterator",
"helpers",
"from",
"map",
"filter",
"take",
"drop",
"flatMap",
"reduce",
"toArray",
"forEach",
"some",
"every",
"find"
],
"author": "Jordan Harband <ljharb@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/es-shims/iterator-helpers/issues"
},
"homepage": "https://github.com/es-shims/iterator-helpers#readme",
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1",
"es-abstract": "^1.23.3",
"es-errors": "^1.3.0",
"es-set-tostringtag": "^2.0.3",
"function-bind": "^1.1.2",
"get-intrinsic": "^1.2.4",
"globalthis": "^1.0.4",
"has-property-descriptors": "^1.0.2",
"has-proto": "^1.0.3",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.7",
"iterator.prototype": "^1.1.3",
"safe-array-concat": "^1.1.2"
},
"devDependencies": {
"@es-shims/api": "^2.5.1",
"@ljharb/eslint-config": "^21.1.1",
"auto-changelog": "^2.5.0",
"encoding": "^0.1.13",
"es-value-fixtures": "^1.5.0",
"eslint": "=8.8.0",
"eslint-plugin-import": "^2.31.0",
"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"functions-have-names": "^1.2.3",
"has-strict-mode": "^1.0.1",
"has-tostringtag": "^1.0.2",
"in-publish": "^2.0.1",
"iterate-iterator": "^1.0.2",
"make-generator-function": "^2.0.0",
"mock-property": "^1.1.0",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"object-inspect": "^1.13.2",
"safe-publish-latest": "^2.0.0",
"tape": "^5.9.0"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows"
]
},
"engines": {
"node": ">= 0.4"
}
}

37
node_modules/es-iterator-helpers/shim.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var shimIterator = require('./Iterator/shim');
var shimIteratorFrom = require('./Iterator.from/shim');
var shimIteratorConcat = require('./Iterator.concat/shim');
var shimIteratorProto = require('./Iterator.prototype/shim');
var shimIteratorCtor = require('./Iterator.prototype.constructor/shim');
var shimIteratorDrop = require('./Iterator.prototype.drop/shim');
var shimIteratorEvery = require('./Iterator.prototype.every/shim');
var shimIteratorFilter = require('./Iterator.prototype.filter/shim');
var shimIteratorFind = require('./Iterator.prototype.find/shim');
var shimIteratorFlatMap = require('./Iterator.prototype.flatMap/shim');
var shimIteratorForEach = require('./Iterator.prototype.forEach/shim');
var shimIteratorMap = require('./Iterator.prototype.map/shim');
var shimIteratorReduce = require('./Iterator.prototype.reduce/shim');
var shimIteratorSome = require('./Iterator.prototype.some/shim');
var shimIteratorTake = require('./Iterator.prototype.take/shim');
var shimIteratorToArray = require('./Iterator.prototype.toArray/shim');
module.exports = function shimIteratorHelpers() {
shimIterator();
shimIteratorFrom();
shimIteratorConcat();
shimIteratorProto();
shimIteratorCtor();
shimIteratorDrop();
shimIteratorEvery();
shimIteratorFilter();
shimIteratorFind();
shimIteratorFlatMap();
shimIteratorForEach();
shimIteratorMap();
shimIteratorReduce();
shimIteratorSome();
shimIteratorTake();
shimIteratorToArray();
};

View File

@@ -0,0 +1,127 @@
'use strict';
var defineProperties = require('define-properties');
var test = require('tape');
var callBind = require('call-bind');
var functionsHaveNames = require('functions-have-names')();
var forEach = require('for-each');
var debug = require('object-inspect');
var v = require('es-value-fixtures');
var hasSymbols = require('has-symbols/shams')();
var mockProperty = require('mock-property');
var index = require('../Iterator.concat');
var impl = require('../Iterator.concat/implementation');
var from = require('../Iterator.from/polyfill')();
var isEnumerable = Object.prototype.propertyIsEnumerable;
var testIterator = require('./helpers/testIterator');
module.exports = {
tests: function (concat, name, t) {
t['throws'](
function () { return new concat(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` itself is not a constructor'
);
t['throws'](
function () { return new concat({}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` itself is not a constructor, with an argument'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {
t['throws'](
function () { concat(nonIterator); },
TypeError,
debug(nonIterator) + ' is not an iterable Object'
);
});
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
forEach(v.nonFunctions, function (nonFunction) {
var badIterable = {};
badIterable[Symbol.iterator] = nonFunction;
st['throws'](
function () { concat([], badIterable, []).next(); },
TypeError,
debug(badIterable) + ' is not a function'
);
});
forEach(v.strings, function (string) {
st['throws'](
function () { concat(string); },
TypeError,
'non-objects are not considered iterable'
);
var stringIt = concat(['a'], [string], ['c']);
testIterator(stringIt, ['a', string, 'c'], st, 'string iterator: ' + debug(string));
});
var arrayIt = concat([1, 2, 3]);
st.equal(typeof arrayIt.next, 'function', 'has a `next` function');
st.test('real iterators', { skip: !hasSymbols }, function (s2t) {
var iter = [1, 2][Symbol.iterator]();
testIterator(concat(iter, [3]), [1, 2, 3], s2t, 'array iterator + array yields combined results');
s2t.end();
});
st.test('observability in a replaced String iterator', function (s2t) {
var originalStringIterator = String.prototype[Symbol.iterator];
var observedType;
s2t.teardown(mockProperty(String.prototype, Symbol.iterator, {
get: function () {
'use strict'; // eslint-disable-line strict, lines-around-directive
observedType = typeof this;
return originalStringIterator;
}
}));
concat(from(''));
s2t.equal(observedType, 'string', 'string primitive -> primitive receiver in Symbol.iterator getter');
concat(from(Object('')));
s2t.equal(observedType, 'object', 'boxed string -> boxed string in Symbol.iterator getter');
s2t.end();
});
st.end();
});
},
index: function () {
test('Iterator.concat: index', function (t) {
module.exports.tests(index, 'Iterator.concat', t);
t.end();
});
},
implementation: function () {
test('Iterator.concat: implementation', function (t) {
module.exports.tests(impl, 'Iterator.concat', t);
t.end();
});
},
shimmed: function () {
test('Iterator.concat: shimmed', function (t) {
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(Iterator.concat.name, 'concat', 'Iterator.concat has name "concat"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(Iterator, 'concat'), 'Iterator.concat is not enumerable');
et.end();
});
module.exports.tests(callBind(Iterator.concat, Iterator), 'Iterator.concat', t);
t.end();
});
}
};

Some files were not shown because too many files have changed in this diff Show More