This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

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

@@ -0,0 +1,92 @@
{
"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",
"CreateDataPropertyOrThrow",
"CreateIteratorFromClosure",
"CreateIterResultObject",
"GeneratorResume",
"GeneratorResumeAbrupt",
"GeneratorStart",
"GeneratorValidate",
"Get",
"GetIntrinsic",
"GetIterator",
"GetIteratorDirect",
"GetIteratorFlattenable",
"GetMethod",
"GetOptionsObject",
"IfAbruptCloseIterators",
"IsAccessorDescriptor",
"IsArray",
"IsCallable",
"IsDataDescriptor",
"IteratorClose",
"IteratorCloseAll",
"IteratorStep",
"IteratorStepValue",
"IteratorZip",
"NormalCompletion",
"OrdinaryHasInstance",
"OrdinaryObjectCreate",
"ReturnCompletion",
"StringToCodePoints",
"ThrowCompletion",
"ToBoolean",
"ToIntegerOrInfinity",
"ToNumber",
"ToPropertyDescriptor",
"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"],
"func-style": 0,
"max-params": 0,
"import/no-extraneous-dependencies": [2, { "devDependencies": true }],
},
},
{
"files": "Iterator.zip*/implementation.js",
"rules": {
"complexity": "off",
"max-depth": "off",
},
},
{
"files": "aos/IteratorZip.js",
"rules": {
"max-depth": "off",
"max-params": "off",
},
},
],
}

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
frontend/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"
]
}

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

@@ -0,0 +1,212 @@
# 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.2.1](https://github.com/es-shims/iterator-helpers/compare/v1.2.0...v1.2.1) - 2024-12-20
### Commits
- [Tests] `Iterator.concat`: add most of the tests from https://github.com/tc39/test262/pull/4326 [`2e340da`](https://github.com/es-shims/iterator-helpers/commit/2e340daf021139ea41dc828c7f99452114db8561)
- [Fix] `Iterator.concat`: rewrite implementation to match updated spec text [`1a70fd3`](https://github.com/es-shims/iterator-helpers/commit/1a70fd33ab81738ad2b748812a431d51e0c4d758)
- [Fix] `IteratorZip` AO: allow an empty list of iterators [`265e566`](https://github.com/es-shims/iterator-helpers/commit/265e5664dade59e2faa5d7d2e203b92cd0af5c35)
- [actions] split out node 10-20, and 20+ [`3cc9db0`](https://github.com/es-shims/iterator-helpers/commit/3cc9db03118e2b4b6432e262e7936a7e2f3074c4)
- [Fix] `IteratorHelperPrototype`: in pre-proto envs, use same `.return` impl [`da02ab6`](https://github.com/es-shims/iterator-helpers/commit/da02ab656dce1c4f73355290a3bd9e4c25ccc3b6)
- [Deps] update `call-bind`, `es-abstract`, `get-intrinsic`, `gopd`, `has-proto`, `internal-slot`, `iterator.prototype`, `safe-array-concat` [`e9eefab`](https://github.com/es-shims/iterator-helpers/commit/e9eefab99fb496f9a4600193126c69c321394d42)
- [Tests] `Iterator.zip`: nullish non-function Symbol.iterator does not throw [`c6b0705`](https://github.com/es-shims/iterator-helpers/commit/c6b0705e2b601c1c8d412679eca4fe4618051d8f)
- [Refactor] use `call-bound` directly [`92afc5a`](https://github.com/es-shims/iterator-helpers/commit/92afc5a7ed014b5e2b52db1b1a6a99d16f50d5d2)
- [Deps] update `gopd`, `has-proto`, `has-symbols` [`7f8a1c0`](https://github.com/es-shims/iterator-helpers/commit/7f8a1c0049dfd649bea9a707b9c451ba7e9f3b0e)
- [readme] add missing info for `Iterator.zip`, `Iterator.zipKeyed` [`dd80b2f`](https://github.com/es-shims/iterator-helpers/commit/dd80b2f1718092219e94e24afdc1737f062e3df4)
- [Dev Deps] update `@es-shims/api` [`1e9857c`](https://github.com/es-shims/iterator-helpers/commit/1e9857c497f8f4e6053c9adb7dddb98b6800c628)
- [Deps] update `es-abstract` [`c8157da`](https://github.com/es-shims/iterator-helpers/commit/c8157da5194372ddc968e0f512d0740544752d30)
- [Deps] update `es-abstract` [`256de0e`](https://github.com/es-shims/iterator-helpers/commit/256de0e1aa45d6d0ad12a19ef04491816bcb7288)
- [Dev Deps] update `object-inspect` [`2f8544b`](https://github.com/es-shims/iterator-helpers/commit/2f8544b7baa80174e7368d475a4e3fa577418938)
## [v1.2.0](https://github.com/es-shims/iterator-helpers/compare/v1.1.0...v1.2.0) - 2024-11-04
### Commits
- [New] add `Iterator.zip`, `Iterator.zipKeyed` [`d11073f`](https://github.com/es-shims/iterator-helpers/commit/d11073fd27fcdaf696c3d9b00634b6a5144f75b1)
- [Fix] `concat`: add missing slot for `.return`; convert singular slot to plural slot [`cc4b586`](https://github.com/es-shims/iterator-helpers/commit/cc4b586cdb0ad6ba540043077c3d71ff79d528cd)
- [Dev Deps] update `@es-shims/api` [`dd14f1b`](https://github.com/es-shims/iterator-helpers/commit/dd14f1b9f06c37f3bcb0a20bacd6e7f031c0724d)
## [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,101 @@
'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 IteratorCloseAll = require('../aos/IteratorCloseAll');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
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 iterablesIndex = 0;
var iteratorRecord;
var innerAlive = false;
var closure = function () { // step 3
if (iterablesIndex >= iterables.length) {
return sentinel;
}
var iterable = iterables[iterablesIndex]; // step 3.a
if (!innerAlive) {
var iter = Call(iterable['[[OpenMethod]]'], iterable['[[Iterable]]']); // step 3.a.i
if (Type(iter) !== 'Object') {
throw new $TypeError('`Iterator.concat` iterator method did not return an object'); // step 3.a.ii
}
iteratorRecord = GetIteratorDirect(iter); // step 3.a.iii
innerAlive = true; // step 3.a.iv
}
if (innerAlive) { // step 3.a.v
var innerValue = IteratorStepValue(iteratorRecord); // step 3.a.v.1
if (iteratorRecord['[[Done]]']) { // step 3.a.v.2
innerAlive = false; // step 3.a.v.2.a
} else { // step 3.a.v.3
// 1. Let completion be Completion(Yield(innerValue)).
return innerValue; // step 3.a.v.3.a
}
}
iterablesIndex += 1;
return closure();
};
var closeIfAbrupt = function (abruptCompletion) {
if (!(abruptCompletion instanceof CompletionRecord)) {
throw new $TypeError('`abruptCompletion` must be a Completion Record');
}
iterablesIndex = iterables.length;
innerAlive = false;
if (iteratorRecord) {
IteratorCloseAll(
[iteratorRecord],
abruptCompletion
);
}
};
SLOT.set(closure, '[[Sentinel]]', sentinel); // for the userland implementation
SLOT.set(closure, '[[CloseIfAbrupt]]', closeIfAbrupt); // for the userland implementation
var gen = CreateIteratorFromClosure(closure, 'Iterator Helper', iterHelperProto, ['[[UnderlyingIterators]]']); // step 5
SLOT.set(gen, '[[UnderlyingIterators]]', []); // step 6
return gen; // step 7
};

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;
};

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, ['[[UnderlyingIterators]]']); // step 4
SLOT.set(result, '[[UnderlyingIterators]]', [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, ['[[UnderlyingIterators]]']); // step 7
SLOT.set(result, '[[UnderlyingIterators]]', [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, ['[[UnderlyingIterators]]']); // step 7
SLOT.set(result, '[[UnderlyingIterators]]', [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, ['[[UnderlyingIterators]]']); // step 7
SLOT.set(result, '[[UnderlyingIterators]]', [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, ['[[UnderlyingIterators]]']); // step 7
SLOT.set(result, '[[UnderlyingIterators]]', [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,32 @@
'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');
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
}
items[items.length] = 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;
};

View File

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

View File

@@ -0,0 +1,122 @@
'use strict';
var $TypeError = require('es-errors/type');
var Get = require('es-abstract/2024/Get');
var GetIterator = require('es-abstract/2024/GetIterator');
var GetIteratorFlattenable = require('../aos/GetIteratorFlattenable');
var GetOptionsObject = require('../aos/GetOptionsObject');
var IfAbruptCloseIterators = require('../aos/IfAbruptCloseIterators');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var IteratorZip = require('../aos/IteratorZip');
var NormalCompletion = require('es-abstract/2024/NormalCompletion');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var Type = require('es-abstract/2024/Type');
module.exports = function zip(iterables) {
if (this instanceof zip) {
throw new $TypeError('`Iterator.zip` is not a constructor');
}
if (Type(iterables) !== 'Object') {
throw new $TypeError('`iterables` must be an Object'); // step 1
}
var options = GetOptionsObject(arguments.length > 1 ? arguments[1] : undefined); // step 2
var mode = Get(options, 'mode'); // step 3
if (typeof mode === 'undefined') {
mode = 'shortest'; // step 4
}
if (mode !== 'shortest' && mode !== 'longest' && mode !== 'strict') {
throw new $TypeError('`mode` must be one of "shortest", "longest", or "strict"'); // step 5
}
var paddingOption; // step 6
if (mode === 'longest') {
paddingOption = Get(options, 'padding'); // step 7
if (typeof paddingOption !== 'undefined' && Type(paddingOption) !== 'Object') {
throw new $TypeError('`padding` option must be an Object'); // step 7.1
}
}
var iters = []; // step 8
var padding = []; // step 9
var inputIter = GetIterator(iterables, 'SYNC'); // step 10
var next; // = 'NOT-STARTED'; // step 11
while (!inputIter['[[Done]]']) { // step 12
try {
next = IteratorStepValue(inputIter); // step 12.a
} catch (e) {
IfAbruptCloseIterators(ThrowCompletion(e), iters); // step 12.b
}
if (!inputIter['[[Done]]']) { // step 12.c
var iter;
try {
iter = GetIteratorFlattenable(next, 'REJECT-STRINGS'); // step 12.c.i
} catch (e) {
IfAbruptCloseIterators(ThrowCompletion(e), [].concat(inputIter, iters)); // step 12.c.ii
}
iters[iters.length] = iter; // step 12.c.iii
}
}
var iterCount = iters.length; // step 13
if (mode === 'longest') { // step 14
if (typeof paddingOption === 'undefined') { // step 14.a
for (var i = 0; i < iterCount; i++) { // step 14.a.i
padding[padding.length] = void undefined; // step 14.a.i.1
}
} else { // step 14.b
var paddingIter;
try {
paddingIter = GetIterator(paddingOption, 'SYNC'); // step 14.b.i
} catch (e) {
IfAbruptCloseIterators(ThrowCompletion(e), iters); // step 14.b.ii
}
var usingIterator = true; // step 14.b.iii
for (var j = 0; j < iterCount; j++) { // step 14.b.iv
if (usingIterator) { // step 14.b.iv.1
try {
next = IteratorStepValue(paddingIter); // step 14.b.iv.1.a
} catch (e) {
IfAbruptCloseIterators(ThrowCompletion(e), iters); // step 14.b.iv.1.b
}
if (paddingIter['[[Done]]']) { // step 14.b.iv.1.c
usingIterator = false; // step 14.b.iv.1.c.i
} else { // step 14.b.iv.1.d
padding[padding.length] = next; // step 14.b.iv.1.d.i
}
}
if (!usingIterator) {
padding[padding.length] = void undefined; // step 14.b.iv.2
}
}
if (usingIterator) { // step 14.b.v
try {
IteratorClose(paddingIter, NormalCompletion(undefined)); // step 14.b.v.1
} catch (e) {
IfAbruptCloseIterators(ThrowCompletion(e), iters); // step 14.b.v.2
}
}
}
}
// eslint-disable-next-line no-sequences
var finishResults = (0, function (results) { // step 15
return results; // step 15.1
});
return IteratorZip(iters, mode, padding, finishResults); // step 16
};

View File

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

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
var $Iterator = require('../Iterator');
module.exports = function getPolyfill() {
return typeof $Iterator.zip === 'function' ? $Iterator.zip : 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 shimIteratorZip() {
var $Iterator = getIteratorPolyfill();
var polyfill = getPolyfill();
define(
$Iterator,
{ zip: polyfill },
{ zip: function () { return $Iterator.zip !== polyfill; } }
);
return polyfill;
};

View File

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

View File

@@ -0,0 +1,133 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('es-abstract/2024/Call');
var CreateDataPropertyOrThrow = require('es-abstract/2024/CreateDataPropertyOrThrow');
var Get = require('es-abstract/2024/Get');
var GetIteratorFlattenable = require('../aos/GetIteratorFlattenable');
var GetOptionsObject = require('../aos/GetOptionsObject');
var IfAbruptCloseIterators = require('../aos/IfAbruptCloseIterators');
var IsAccessorDescriptor = require('es-abstract/2024/IsAccessorDescriptor');
var IsDataDescriptor = require('es-abstract/2024/IsDataDescriptor');
var IteratorZip = require('../aos/IteratorZip');
var OrdinaryObjectCreate = require('es-abstract/2024/OrdinaryObjectCreate');
var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
var ToPropertyDescriptor = require('es-abstract/2024/ToPropertyDescriptor');
var Type = require('es-abstract/2024/Type');
var forEach = require('es-abstract/helpers/forEach');
var ownKeys = require('es-abstract/helpers/OwnPropertyKeys');
var gOPD = require('gopd');
module.exports = function zipKeyed(iterables) {
if (this instanceof zipKeyed) {
throw new $TypeError('`Iterator.zip` is not a constructor');
}
if (Type(iterables) !== 'Object') {
throw new $TypeError('`iterables` must be an Object'); // step 1
}
var options = GetOptionsObject(arguments.length > 1 ? arguments[1] : undefined); // step 2
var mode = Get(options, 'mode'); // step 3
if (typeof mode === 'undefined') {
mode = 'shortest'; // step 4
}
if (mode !== 'shortest' && mode !== 'longest' && mode !== 'strict') {
throw new $TypeError('`mode` must be one of "shortest", "longest", or "strict"'); // step 5
}
var paddingOption; // step 6
if (mode === 'longest') { // step 7
paddingOption = Get(options, 'padding'); // step 7.a
if (typeof paddingOption !== 'undefined' && Type(paddingOption) !== 'Object') {
throw new $TypeError('`padding` option must be an Object'); // step 7.b
}
}
var iters = []; // step 8
var padding = []; // step 9
var allKeys = ownKeys(iterables); // step 10
var keys = []; // step 11
forEach(allKeys, function (key) { // step 12
var desc;
try {
desc = ToPropertyDescriptor(gOPD(iterables, key)); // step 12.a
} catch (e) {
IfAbruptCloseIterators(ThrowCompletion(e), iters); // step 12.b
}
if (typeof desc !== 'undefined' && desc['[[Enumerable]]'] === true) { // step 12.c
var value; // step 12.c.i
if (IsDataDescriptor(desc)) { // step 12.c.ii
value = desc['[[Value]]']; // step 12.c.ii.1
} else {
if (!IsAccessorDescriptor(desc)) {
throw new $TypeError('Assertion failed: IsAccessorDescriptor(desc) is not true'); // step 12.c.ii.1
}
var getter = desc['[[Get]]']; // step 12.c.iii.2
if (typeof getter !== 'undefined') { // step 12.c.iii.3
var getterResult;
try {
getterResult = Call(getter, iterables); // step 12.c.iii.3.a
} catch (e) {
// step 12.c.iii.3.b
// 2. IfAbruptCloseIterators(e, iters).
}
value = getterResult; // step 12.c.iii.3.c
}
}
if (typeof value !== 'undefined') { // step 12.c.iv
keys[keys.length] = key; // step 12.c.iv.1
var iter;
try {
iter = GetIteratorFlattenable(value, 'REJECT-STRINGS'); // step 12.c.iv.2
} catch (e) {
IfAbruptCloseIterators(ThrowCompletion(e), iters); // step 12.c.iv.3
}
iters[iters.length] = iter; // step 12.c.iv.4
}
}
});
var iterCount = iters.length; // step 13
if (mode === 'longest') { // step 14
if (typeof paddingOption === 'undefined') { // step 14.a
for (var j = 0; j < iterCount; j += 1) { // step 14.a.i
padding[padding.length] = void undefined; // step 14.a.i.1
}
} else { // step 14.b
forEach(keys, function (key) { // step 14.b.i
var value;
try {
value = Get(paddingOption, key); // step 14.b.i.1
} catch (e) {
IfAbruptCloseIterators(ThrowCompletion(e), iters); // step 14.b.i.2
}
padding[padding.length] = value; // step 14.b.i.3
});
}
}
// eslint-disable-next-line no-sequences
var finishResults = (0, function (results) { // step 15
var obj = OrdinaryObjectCreate(null); // step 15.a
for (var i = 0; i < iterCount; i += 1) { // step 15.b
CreateDataPropertyOrThrow(obj, keys[i], results[i]); // step 15.b.i
}
return obj; // step 15.c
});
return IteratorZip(iters, mode, padding, finishResults); // step 16
};

View File

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

View File

@@ -0,0 +1,9 @@
'use strict';
var implementation = require('./implementation');
var $Iterator = require('../Iterator');
module.exports = function getPolyfill() {
return typeof $Iterator.zipKeyed === 'function' ? $Iterator.zipKeyed : 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 shimIteratorZipKeyed() {
var $Iterator = getIteratorPolyfill();
var polyfill = getPolyfill();
define(
$Iterator,
{ zipKeyed: polyfill },
{ zipKeyed: function () { return $Iterator.zipKeyed !== polyfill; } }
);
return polyfill;
};

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-bound');
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;

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;
};

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,54 @@
'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 CreateIterResultObject = require('es-abstract/2024/CreateIterResultObject');
var GeneratorResume = require('../aos/GeneratorResume');
var GeneratorResumeAbrupt = require('../aos/GeneratorResumeAbrupt');
var IteratorCloseAll = require('../aos/IteratorCloseAll');
var ReturnCompletion = require('../aos/ReturnCompletion');
var implementation;
var o = { // in an object, for name inference
'return': function () {
var O = this; // step 1
SLOT.assert(O, '[[UnderlyingIterators]]'); // step 2
SLOT.assert(O, '[[GeneratorState]]'); // step 3
if (SLOT.get(O, '[[GeneratorState]]') === 'suspendedStart') { // step 4
SLOT.set(O, '[[GeneratorState]]', 'completed'); // step 4.a
IteratorCloseAll(SLOT.get(O, '[[UnderlyingIterators]]'), ReturnCompletion(void undefined)); // step 4.c
return CreateIterResultObject(void undefined, true); // step 4.d
}
var C = ReturnCompletion(void undefined); // step 5
return GeneratorResumeAbrupt(O, C, 'Iterator Helper'); // step 6
}
};
if (hasProto) {
implementation = {
__proto__: iterProto,
next: function next() {
return GeneratorResume(this, void undefined, 'Iterator Helper');
},
'return': o['return']
};
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'] = o['return'];
}
module.exports = implementation;

21
frontend/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.

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

@@ -0,0 +1,110 @@
# 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.zip`](https://tc39.es/proposal-joint-iteration/#sec-iterator.zip)
- [`Iterator.zipKeyed`](https://tc39.es/proposal-joint-iteration/#sec-iterator.zipkeyed)
- [`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, Iterator.zip, Iterator.zipKeyed
## 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;
};

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