Upload folder using huggingface_hub (part 24)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- node_modules/es-iterator-helpers/index.json +20 -0
- node_modules/es-iterator-helpers/package.json +206 -0
- node_modules/es-iterator-helpers/shim.js +41 -0
- node_modules/es-iterator-helpers/test/Iterator.concat.js +718 -0
- node_modules/es-iterator-helpers/test/Iterator.from.js +322 -0
- node_modules/es-iterator-helpers/test/Iterator.js +95 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.constructor.js +57 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.drop.js +458 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.every.js +289 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.filter.js +559 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.find.js +286 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.flatMap.js +238 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.forEach.js +232 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.js +72 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.map.js +463 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.reduce.js +318 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.some.js +286 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.take.js +364 -0
- node_modules/es-iterator-helpers/test/Iterator.prototype.toArray.js +286 -0
- node_modules/es-iterator-helpers/test/Iterator.zip.js +278 -0
- node_modules/es-iterator-helpers/test/Iterator.zipKeyed.js +349 -0
- node_modules/es-iterator-helpers/test/helpers/testIterator.js +7 -0
- node_modules/es-iterator-helpers/test/implementation.js +18 -0
- node_modules/es-iterator-helpers/test/index.js +20 -0
- node_modules/es-iterator-helpers/test/shimmed.js +70 -0
- node_modules/es-iterator-helpers/test/tests.js +25 -0
- node_modules/es-module-lexer/LICENSE +10 -0
- node_modules/es-module-lexer/README.md +338 -0
- node_modules/es-module-lexer/dist/lexer.asm.js +2 -0
- node_modules/es-module-lexer/dist/lexer.cjs +1 -0
- node_modules/es-module-lexer/dist/lexer.js +2 -0
- node_modules/es-module-lexer/lexer.js +925 -0
- node_modules/es-module-lexer/package.json +57 -0
- node_modules/es-module-lexer/types/lexer.d.ts +195 -0
- node_modules/es-object-atoms/.eslintrc +16 -0
- node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- node_modules/es-object-atoms/CHANGELOG.md +37 -0
- node_modules/es-object-atoms/LICENSE +21 -0
- node_modules/es-object-atoms/README.md +63 -0
- node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- node_modules/es-object-atoms/ToObject.d.ts +7 -0
- node_modules/es-object-atoms/ToObject.js +10 -0
- node_modules/es-object-atoms/index.d.ts +3 -0
- node_modules/es-object-atoms/index.js +4 -0
- node_modules/es-object-atoms/isObject.d.ts +3 -0
- node_modules/es-object-atoms/isObject.js +6 -0
- node_modules/es-object-atoms/package.json +80 -0
- node_modules/es-object-atoms/test/index.js +38 -0
.gitattributes
CHANGED
|
@@ -51,3 +51,4 @@ node_modules/@unrs/resolver-binding-linux-x64-musl/resolver.linux-x64-musl.node
|
|
| 51 |
node_modules/bcrypt/prebuilds/win32-arm64/bcrypt.node filter=lfs diff=lfs merge=lfs -text
|
| 52 |
node_modules/bcrypt/prebuilds/win32-x64/bcrypt.node filter=lfs diff=lfs merge=lfs -text
|
| 53 |
node_modules/better-sqlite3/build/Release/better_sqlite3.node filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 51 |
node_modules/bcrypt/prebuilds/win32-arm64/bcrypt.node filter=lfs diff=lfs merge=lfs -text
|
| 52 |
node_modules/bcrypt/prebuilds/win32-x64/bcrypt.node filter=lfs diff=lfs merge=lfs -text
|
| 53 |
node_modules/better-sqlite3/build/Release/better_sqlite3.node filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
node_modules/esbuild/bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
node_modules/es-iterator-helpers/index.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"Iterator",
|
| 3 |
+
"Iterator.concat",
|
| 4 |
+
"Iterator.from",
|
| 5 |
+
"Iterator.zip",
|
| 6 |
+
"Iterator.zipKeyed",
|
| 7 |
+
"Iterator.prototype",
|
| 8 |
+
"Iterator.prototype.constructor",
|
| 9 |
+
"Iterator.prototype.drop",
|
| 10 |
+
"Iterator.prototype.every",
|
| 11 |
+
"Iterator.prototype.filter",
|
| 12 |
+
"Iterator.prototype.find",
|
| 13 |
+
"Iterator.prototype.flatMap",
|
| 14 |
+
"Iterator.prototype.forEach",
|
| 15 |
+
"Iterator.prototype.map",
|
| 16 |
+
"Iterator.prototype.reduce",
|
| 17 |
+
"Iterator.prototype.some",
|
| 18 |
+
"Iterator.prototype.take",
|
| 19 |
+
"Iterator.prototype.toArray"
|
| 20 |
+
]
|
node_modules/es-iterator-helpers/package.json
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "es-iterator-helpers",
|
| 3 |
+
"version": "1.2.2",
|
| 4 |
+
"description": "An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3.",
|
| 5 |
+
"main": "index.json",
|
| 6 |
+
"exports": {
|
| 7 |
+
".": "./index.json",
|
| 8 |
+
"./auto": "./auto.js",
|
| 9 |
+
"./shim": "./shim.js",
|
| 10 |
+
"./Iterator": "./Iterator/index.js",
|
| 11 |
+
"./Iterator/auto": "./Iterator/auto.js",
|
| 12 |
+
"./Iterator/polyfill": "./Iterator/polyfill.js",
|
| 13 |
+
"./Iterator/implementation": "./Iterator/implementation.js",
|
| 14 |
+
"./Iterator/shim": "./Iterator/shim.js",
|
| 15 |
+
"./Iterator.prototype": "./Iterator.prototype/index.js",
|
| 16 |
+
"./Iterator.prototype/auto": "./Iterator.prototype/auto.js",
|
| 17 |
+
"./Iterator.prototype/polyfill": "./Iterator.prototype/polyfill.js",
|
| 18 |
+
"./Iterator.prototype/implementation": "./Iterator.prototype/implementation.js",
|
| 19 |
+
"./Iterator.prototype/shim": "./Iterator.prototype/shim.js",
|
| 20 |
+
"./Iterator.concat": "./Iterator.concat/index.js",
|
| 21 |
+
"./Iterator.concat/auto": "./Iterator.concat/auto.js",
|
| 22 |
+
"./Iterator.concat/polyfill": "./Iterator.concat/polyfill.js",
|
| 23 |
+
"./Iterator.concat/implementation": "./Iterator.concat/implementation.js",
|
| 24 |
+
"./Iterator.concat/shim": "./Iterator.concat/shim.js",
|
| 25 |
+
"./Iterator.from": "./Iterator.from/index.js",
|
| 26 |
+
"./Iterator.from/auto": "./Iterator.from/auto.js",
|
| 27 |
+
"./Iterator.from/polyfill": "./Iterator.from/polyfill.js",
|
| 28 |
+
"./Iterator.from/implementation": "./Iterator.from/implementation.js",
|
| 29 |
+
"./Iterator.from/shim": "./Iterator.from/shim.js",
|
| 30 |
+
"./Iterator.zip": "./Iterator.zip/index.js",
|
| 31 |
+
"./Iterator.zip/auto": "./Iterator.zip/auto.js",
|
| 32 |
+
"./Iterator.zip/polyfill": "./Iterator.zip/polyfill.js",
|
| 33 |
+
"./Iterator.zip/implementation": "./Iterator.zip/implementation.js",
|
| 34 |
+
"./Iterator.zip/shim": "./Iterator.zip/shim.js",
|
| 35 |
+
"./Iterator.zipKeyed": "./Iterator.zipKeyed/index.js",
|
| 36 |
+
"./Iterator.zipKeyed/auto": "./Iterator.zipKeyed/auto.js",
|
| 37 |
+
"./Iterator.zipKeyed/polyfill": "./Iterator.zipKeyed/polyfill.js",
|
| 38 |
+
"./Iterator.zipKeyed/implementation": "./Iterator.zipKeyed/implementation.js",
|
| 39 |
+
"./Iterator.zipKeyed/shim": "./Iterator.zipKeyed/shim.js",
|
| 40 |
+
"./Iterator.prototype.constructor": "./Iterator.prototype.constructor/index.js",
|
| 41 |
+
"./Iterator.prototype.constructor/auto": "./Iterator.prototype.constructor/auto.js",
|
| 42 |
+
"./Iterator.prototype.constructor/polyfill": "./Iterator.prototype.constructor/polyfill.js",
|
| 43 |
+
"./Iterator.prototype.constructor/implementation": "./Iterator.prototype.constructor/implementation.js",
|
| 44 |
+
"./Iterator.prototype.constructor/shim": "./Iterator.prototype.constructor/shim.js",
|
| 45 |
+
"./Iterator.prototype.map": "./Iterator.prototype.map/index.js",
|
| 46 |
+
"./Iterator.prototype.map/auto": "./Iterator.prototype.map/auto.js",
|
| 47 |
+
"./Iterator.prototype.map/polyfill": "./Iterator.prototype.map/polyfill.js",
|
| 48 |
+
"./Iterator.prototype.map/implementation": "./Iterator.prototype.map/implementation.js",
|
| 49 |
+
"./Iterator.prototype.map/shim": "./Iterator.prototype.map/shim.js",
|
| 50 |
+
"./Iterator.prototype.filter": "./Iterator.prototype.filter/index.js",
|
| 51 |
+
"./Iterator.prototype.filter/auto": "./Iterator.prototype.filter/auto.js",
|
| 52 |
+
"./Iterator.prototype.filter/polyfill": "./Iterator.prototype.filter/polyfill.js",
|
| 53 |
+
"./Iterator.prototype.filter/implementation": "./Iterator.prototype.filter/implementation.js",
|
| 54 |
+
"./Iterator.prototype.filter/shim": "./Iterator.prototype.filter/shim.js",
|
| 55 |
+
"./Iterator.prototype.take": "./Iterator.prototype.take/index.js",
|
| 56 |
+
"./Iterator.prototype.take/auto": "./Iterator.prototype.take/auto.js",
|
| 57 |
+
"./Iterator.prototype.take/polyfill": "./Iterator.prototype.take/polyfill.js",
|
| 58 |
+
"./Iterator.prototype.take/implementation": "./Iterator.prototype.take/implementation.js",
|
| 59 |
+
"./Iterator.prototype.take/shim": "./Iterator.prototype.take/shim.js",
|
| 60 |
+
"./Iterator.prototype.drop": "./Iterator.prototype.drop/index.js",
|
| 61 |
+
"./Iterator.prototype.drop/auto": "./Iterator.prototype.drop/auto.js",
|
| 62 |
+
"./Iterator.prototype.drop/polyfill": "./Iterator.prototype.drop/polyfill.js",
|
| 63 |
+
"./Iterator.prototype.drop/implementation": "./Iterator.prototype.drop/implementation.js",
|
| 64 |
+
"./Iterator.prototype.drop/shim": "./Iterator.prototype.drop/shim.js",
|
| 65 |
+
"./Iterator.prototype.flatMap": "./Iterator.prototype.flatMap/index.js",
|
| 66 |
+
"./Iterator.prototype.flatMap/auto": "./Iterator.prototype.flatMap/auto.js",
|
| 67 |
+
"./Iterator.prototype.flatMap/polyfill": "./Iterator.prototype.flatMap/polyfill.js",
|
| 68 |
+
"./Iterator.prototype.flatMap/implementation": "./Iterator.prototype.flatMap/implementation.js",
|
| 69 |
+
"./Iterator.prototype.flatMap/shim": "./Iterator.prototype.flatMap/shim.js",
|
| 70 |
+
"./Iterator.prototype.reduce": "./Iterator.prototype.reduce/index.js",
|
| 71 |
+
"./Iterator.prototype.reduce/auto": "./Iterator.prototype.reduce/auto.js",
|
| 72 |
+
"./Iterator.prototype.reduce/polyfill": "./Iterator.prototype.reduce/polyfill.js",
|
| 73 |
+
"./Iterator.prototype.reduce/implementation": "./Iterator.prototype.reduce/implementation.js",
|
| 74 |
+
"./Iterator.prototype.reduce/shim": "./Iterator.prototype.reduce/shim.js",
|
| 75 |
+
"./Iterator.prototype.toArray": "./Iterator.prototype.toArray/index.js",
|
| 76 |
+
"./Iterator.prototype.toArray/auto": "./Iterator.prototype.toArray/auto.js",
|
| 77 |
+
"./Iterator.prototype.toArray/polyfill": "./Iterator.prototype.toArray/polyfill.js",
|
| 78 |
+
"./Iterator.prototype.toArray/implementation": "./Iterator.prototype.toArray/implementation.js",
|
| 79 |
+
"./Iterator.prototype.toArray/shim": "./Iterator.prototype.toArray/shim.js",
|
| 80 |
+
"./Iterator.prototype.forEach": "./Iterator.prototype.forEach/index.js",
|
| 81 |
+
"./Iterator.prototype.forEach/auto": "./Iterator.prototype.forEach/auto.js",
|
| 82 |
+
"./Iterator.prototype.forEach/polyfill": "./Iterator.prototype.forEach/polyfill.js",
|
| 83 |
+
"./Iterator.prototype.forEach/implementation": "./Iterator.prototype.forEach/implementation.js",
|
| 84 |
+
"./Iterator.prototype.forEach/shim": "./Iterator.prototype.forEach/shim.js",
|
| 85 |
+
"./Iterator.prototype.some": "./Iterator.prototype.some/index.js",
|
| 86 |
+
"./Iterator.prototype.some/auto": "./Iterator.prototype.some/auto.js",
|
| 87 |
+
"./Iterator.prototype.some/polyfill": "./Iterator.prototype.some/polyfill.js",
|
| 88 |
+
"./Iterator.prototype.some/implementation": "./Iterator.prototype.some/implementation.js",
|
| 89 |
+
"./Iterator.prototype.some/shim": "./Iterator.prototype.some/shim.js",
|
| 90 |
+
"./Iterator.prototype.every": "./Iterator.prototype.every/index.js",
|
| 91 |
+
"./Iterator.prototype.every/auto": "./Iterator.prototype.every/auto.js",
|
| 92 |
+
"./Iterator.prototype.every/polyfill": "./Iterator.prototype.every/polyfill.js",
|
| 93 |
+
"./Iterator.prototype.every/implementation": "./Iterator.prototype.every/implementation.js",
|
| 94 |
+
"./Iterator.prototype.every/shim": "./Iterator.prototype.every/shim.js",
|
| 95 |
+
"./Iterator.prototype.find": "./Iterator.prototype.find/index.js",
|
| 96 |
+
"./Iterator.prototype.find/auto": "./Iterator.prototype.find/auto.js",
|
| 97 |
+
"./Iterator.prototype.find/polyfill": "./Iterator.prototype.find/polyfill.js",
|
| 98 |
+
"./Iterator.prototype.find/implementation": "./Iterator.prototype.find/implementation.js",
|
| 99 |
+
"./Iterator.prototype.find/shim": "./Iterator.prototype.find/shim.js",
|
| 100 |
+
"./package.json": "./package.json"
|
| 101 |
+
},
|
| 102 |
+
"scripts": {
|
| 103 |
+
"prepack": "npmignore --auto --commentLines=autogenerated",
|
| 104 |
+
"prepublishOnly": "safe-publish-latest",
|
| 105 |
+
"prepublish": "not-in-publish || npm run prepublishOnly",
|
| 106 |
+
"prelint": "es-shim-api --type=multi --ignore-dirs=WrapForValidIteratorPrototype,IteratorHelperPrototype",
|
| 107 |
+
"lint": "eslint --ext=js,mjs .",
|
| 108 |
+
"postlint": "evalmd README.md",
|
| 109 |
+
"pretest": "npm run lint",
|
| 110 |
+
"test": "npm run tests-only",
|
| 111 |
+
"tests-only": "nyc tape 'test/**/*.js'",
|
| 112 |
+
"posttest": "npx npm@'>=10.2' audit --production",
|
| 113 |
+
"version": "auto-changelog && git add CHANGELOG.md",
|
| 114 |
+
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
| 115 |
+
},
|
| 116 |
+
"repository": {
|
| 117 |
+
"type": "git",
|
| 118 |
+
"url": "git+https://github.com/es-shims/iterator-helpers.git"
|
| 119 |
+
},
|
| 120 |
+
"keywords": [
|
| 121 |
+
"javascript",
|
| 122 |
+
"ecmascript",
|
| 123 |
+
"polyfill",
|
| 124 |
+
"shim",
|
| 125 |
+
"es-shims",
|
| 126 |
+
"es-shim API",
|
| 127 |
+
"Iterator",
|
| 128 |
+
"helpers",
|
| 129 |
+
"from",
|
| 130 |
+
"map",
|
| 131 |
+
"filter",
|
| 132 |
+
"take",
|
| 133 |
+
"drop",
|
| 134 |
+
"flatMap",
|
| 135 |
+
"reduce",
|
| 136 |
+
"toArray",
|
| 137 |
+
"forEach",
|
| 138 |
+
"some",
|
| 139 |
+
"every",
|
| 140 |
+
"find"
|
| 141 |
+
],
|
| 142 |
+
"author": "Jordan Harband <ljharb@gmail.com>",
|
| 143 |
+
"license": "MIT",
|
| 144 |
+
"bugs": {
|
| 145 |
+
"url": "https://github.com/es-shims/iterator-helpers/issues"
|
| 146 |
+
},
|
| 147 |
+
"homepage": "https://github.com/es-shims/iterator-helpers#readme",
|
| 148 |
+
"dependencies": {
|
| 149 |
+
"call-bind": "^1.0.8",
|
| 150 |
+
"call-bound": "^1.0.4",
|
| 151 |
+
"define-properties": "^1.2.1",
|
| 152 |
+
"es-abstract": "^1.24.1",
|
| 153 |
+
"es-errors": "^1.3.0",
|
| 154 |
+
"es-set-tostringtag": "^2.1.0",
|
| 155 |
+
"function-bind": "^1.1.2",
|
| 156 |
+
"get-intrinsic": "^1.3.0",
|
| 157 |
+
"globalthis": "^1.0.4",
|
| 158 |
+
"gopd": "^1.2.0",
|
| 159 |
+
"has-property-descriptors": "^1.0.2",
|
| 160 |
+
"has-proto": "^1.2.0",
|
| 161 |
+
"has-symbols": "^1.1.0",
|
| 162 |
+
"internal-slot": "^1.1.0",
|
| 163 |
+
"iterator.prototype": "^1.1.5",
|
| 164 |
+
"safe-array-concat": "^1.1.3"
|
| 165 |
+
},
|
| 166 |
+
"devDependencies": {
|
| 167 |
+
"@es-shims/api": "^3.0.3",
|
| 168 |
+
"@ljharb/eslint-config": "^22.1.2",
|
| 169 |
+
"auto-changelog": "^2.5.0",
|
| 170 |
+
"encoding": "^0.1.13",
|
| 171 |
+
"es-value-fixtures": "^1.7.1",
|
| 172 |
+
"eslint": "^9.39.2",
|
| 173 |
+
"eslint-plugin-import": "^2.32.0",
|
| 174 |
+
"evalmd": "^0.0.19",
|
| 175 |
+
"for-each": "^0.3.5",
|
| 176 |
+
"functions-have-names": "^1.2.3",
|
| 177 |
+
"has-strict-mode": "^1.1.0",
|
| 178 |
+
"has-tostringtag": "^1.0.2",
|
| 179 |
+
"in-publish": "^2.0.1",
|
| 180 |
+
"iterate-iterator": "^1.0.2",
|
| 181 |
+
"jiti": "^0.0.0",
|
| 182 |
+
"make-generator-function": "^2.1.0",
|
| 183 |
+
"mock-property": "^1.1.0",
|
| 184 |
+
"npmignore": "^0.3.2",
|
| 185 |
+
"nyc": "^10.3.2",
|
| 186 |
+
"object-inspect": "^1.13.4",
|
| 187 |
+
"safe-publish-latest": "^2.0.0",
|
| 188 |
+
"tape": "^5.9.0"
|
| 189 |
+
},
|
| 190 |
+
"auto-changelog": {
|
| 191 |
+
"output": "CHANGELOG.md",
|
| 192 |
+
"template": "keepachangelog",
|
| 193 |
+
"unreleased": false,
|
| 194 |
+
"commitLimit": false,
|
| 195 |
+
"backfillLimit": false,
|
| 196 |
+
"hideCredit": true
|
| 197 |
+
},
|
| 198 |
+
"publishConfig": {
|
| 199 |
+
"ignore": [
|
| 200 |
+
".github/workflows"
|
| 201 |
+
]
|
| 202 |
+
},
|
| 203 |
+
"engines": {
|
| 204 |
+
"node": ">= 0.4"
|
| 205 |
+
}
|
| 206 |
+
}
|
node_modules/es-iterator-helpers/shim.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var shimIterator = require('./Iterator/shim');
|
| 4 |
+
var shimIteratorFrom = require('./Iterator.from/shim');
|
| 5 |
+
var shimIteratorConcat = require('./Iterator.concat/shim');
|
| 6 |
+
var shimZip = require('./Iterator.zip/shim');
|
| 7 |
+
var shimZipKeyed = require('./Iterator.zipKeyed/shim');
|
| 8 |
+
var shimIteratorProto = require('./Iterator.prototype/shim');
|
| 9 |
+
var shimIteratorCtor = require('./Iterator.prototype.constructor/shim');
|
| 10 |
+
var shimIteratorDrop = require('./Iterator.prototype.drop/shim');
|
| 11 |
+
var shimIteratorEvery = require('./Iterator.prototype.every/shim');
|
| 12 |
+
var shimIteratorFilter = require('./Iterator.prototype.filter/shim');
|
| 13 |
+
var shimIteratorFind = require('./Iterator.prototype.find/shim');
|
| 14 |
+
var shimIteratorFlatMap = require('./Iterator.prototype.flatMap/shim');
|
| 15 |
+
var shimIteratorForEach = require('./Iterator.prototype.forEach/shim');
|
| 16 |
+
var shimIteratorMap = require('./Iterator.prototype.map/shim');
|
| 17 |
+
var shimIteratorReduce = require('./Iterator.prototype.reduce/shim');
|
| 18 |
+
var shimIteratorSome = require('./Iterator.prototype.some/shim');
|
| 19 |
+
var shimIteratorTake = require('./Iterator.prototype.take/shim');
|
| 20 |
+
var shimIteratorToArray = require('./Iterator.prototype.toArray/shim');
|
| 21 |
+
|
| 22 |
+
module.exports = function shimIteratorHelpers() {
|
| 23 |
+
shimIterator();
|
| 24 |
+
shimIteratorProto();
|
| 25 |
+
shimIteratorFrom();
|
| 26 |
+
shimIteratorConcat();
|
| 27 |
+
shimZip();
|
| 28 |
+
shimZipKeyed();
|
| 29 |
+
shimIteratorCtor();
|
| 30 |
+
shimIteratorDrop();
|
| 31 |
+
shimIteratorEvery();
|
| 32 |
+
shimIteratorFilter();
|
| 33 |
+
shimIteratorFind();
|
| 34 |
+
shimIteratorFlatMap();
|
| 35 |
+
shimIteratorForEach();
|
| 36 |
+
shimIteratorMap();
|
| 37 |
+
shimIteratorReduce();
|
| 38 |
+
shimIteratorSome();
|
| 39 |
+
shimIteratorTake();
|
| 40 |
+
shimIteratorToArray();
|
| 41 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.concat.js
ADDED
|
@@ -0,0 +1,718 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var forEach = require('for-each');
|
| 8 |
+
var debug = require('object-inspect');
|
| 9 |
+
var v = require('es-value-fixtures');
|
| 10 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 11 |
+
var mockProperty = require('mock-property');
|
| 12 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 13 |
+
|
| 14 |
+
var index = require('../Iterator.concat');
|
| 15 |
+
var impl = require('../Iterator.concat/implementation');
|
| 16 |
+
var from = require('../Iterator.from/polyfill')();
|
| 17 |
+
|
| 18 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 19 |
+
|
| 20 |
+
var testIterator = require('./helpers/testIterator');
|
| 21 |
+
|
| 22 |
+
module.exports = {
|
| 23 |
+
tests: function (concat, name, t) {
|
| 24 |
+
t['throws'](
|
| 25 |
+
function () { return new concat(); }, // eslint-disable-line new-cap
|
| 26 |
+
TypeError,
|
| 27 |
+
'`' + name + '` itself is not a constructor'
|
| 28 |
+
);
|
| 29 |
+
t['throws'](
|
| 30 |
+
function () { return new concat({}); }, // eslint-disable-line new-cap
|
| 31 |
+
TypeError,
|
| 32 |
+
'`' + name + '` itself is not a constructor, with an argument'
|
| 33 |
+
);
|
| 34 |
+
|
| 35 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 36 |
+
t['throws'](
|
| 37 |
+
function () { concat(nonIterator); },
|
| 38 |
+
TypeError,
|
| 39 |
+
debug(nonIterator) + ' is not an iterable Object'
|
| 40 |
+
);
|
| 41 |
+
});
|
| 42 |
+
|
| 43 |
+
t.deepEqual(concat().next(), { value: undefined, done: true }, 'no arguments -> empty iterator');
|
| 44 |
+
|
| 45 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 46 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 47 |
+
var badIterable = {};
|
| 48 |
+
badIterable[Symbol.iterator] = nonFunction;
|
| 49 |
+
st['throws'](
|
| 50 |
+
function () { concat([], badIterable, []); },
|
| 51 |
+
TypeError,
|
| 52 |
+
debug(badIterable) + '[Symbol.iterator] is not a function'
|
| 53 |
+
);
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
forEach(v.primitives, function (nonObject) {
|
| 57 |
+
var badIterable = {};
|
| 58 |
+
badIterable[Symbol.iterator] = function () { return nonObject; };
|
| 59 |
+
st['throws'](
|
| 60 |
+
function () { concat([], badIterable, []).next(); },
|
| 61 |
+
TypeError,
|
| 62 |
+
debug(badIterable) + '[Symbol.iterator] does not return an object'
|
| 63 |
+
);
|
| 64 |
+
});
|
| 65 |
+
|
| 66 |
+
forEach(v.strings, function (string) {
|
| 67 |
+
st['throws'](
|
| 68 |
+
function () { concat(string); },
|
| 69 |
+
TypeError,
|
| 70 |
+
'non-objects are not considered iterable'
|
| 71 |
+
);
|
| 72 |
+
var stringIt = concat(['a'], [string], ['c']);
|
| 73 |
+
testIterator(stringIt, ['a', string, 'c'], st, 'string iterator: ' + debug(string));
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
var arrayIt = concat([1, 2, 3]);
|
| 77 |
+
st.equal(typeof arrayIt.next, 'function', 'has a `next` function');
|
| 78 |
+
|
| 79 |
+
st.test('real iterators', { skip: !hasSymbols }, function (s2t) {
|
| 80 |
+
var iter = [1, 2][Symbol.iterator]();
|
| 81 |
+
testIterator(concat(iter, [3]), [1, 2, 3], s2t, 'array iterator + array yields combined results');
|
| 82 |
+
|
| 83 |
+
s2t.end();
|
| 84 |
+
});
|
| 85 |
+
|
| 86 |
+
st.test('observability in a replaced String iterator', function (s2t) {
|
| 87 |
+
var originalStringIterator = String.prototype[Symbol.iterator];
|
| 88 |
+
var observedType;
|
| 89 |
+
s2t.teardown(mockProperty(String.prototype, Symbol.iterator, {
|
| 90 |
+
get: function () {
|
| 91 |
+
'use strict'; // eslint-disable-line strict, lines-around-directive
|
| 92 |
+
|
| 93 |
+
observedType = typeof this;
|
| 94 |
+
return originalStringIterator;
|
| 95 |
+
}
|
| 96 |
+
}));
|
| 97 |
+
|
| 98 |
+
concat(from(''));
|
| 99 |
+
s2t.equal(observedType, 'string', 'string primitive -> primitive receiver in Symbol.iterator getter');
|
| 100 |
+
concat(from(Object('')));
|
| 101 |
+
s2t.equal(observedType, 'object', 'boxed string -> boxed string in Symbol.iterator getter');
|
| 102 |
+
|
| 103 |
+
s2t.end();
|
| 104 |
+
});
|
| 105 |
+
|
| 106 |
+
st.test('test262: test/built-ins/Iterator/concat/arguments-checked-in-order', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 107 |
+
var getIterator = 0;
|
| 108 |
+
|
| 109 |
+
var iterable1 = {};
|
| 110 |
+
Object.defineProperty(iterable1, Symbol.iterator, {
|
| 111 |
+
get: function () {
|
| 112 |
+
getIterator += 1;
|
| 113 |
+
return function () {
|
| 114 |
+
throw new EvalError();
|
| 115 |
+
};
|
| 116 |
+
}
|
| 117 |
+
});
|
| 118 |
+
|
| 119 |
+
var iterable2 = {};
|
| 120 |
+
Object.defineProperty(iterable2, Symbol.iterator, {
|
| 121 |
+
get: function () {
|
| 122 |
+
throw new EvalError();
|
| 123 |
+
}
|
| 124 |
+
});
|
| 125 |
+
|
| 126 |
+
s2t.equal(getIterator, 0);
|
| 127 |
+
|
| 128 |
+
s2t['throws'](function () { concat(iterable1, null, iterable2); }, TypeError);
|
| 129 |
+
|
| 130 |
+
s2t.equal(getIterator, 1);
|
| 131 |
+
|
| 132 |
+
s2t.end();
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
+
st.test('test262: test/built-ins/Iterator/concat/fresh-iterator-result', function (s2t) {
|
| 136 |
+
var oldIterResult = {
|
| 137 |
+
done: false,
|
| 138 |
+
value: 123
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
var testIterator1 = {
|
| 142 |
+
next: function () {
|
| 143 |
+
return oldIterResult;
|
| 144 |
+
}
|
| 145 |
+
};
|
| 146 |
+
|
| 147 |
+
var iterable = {};
|
| 148 |
+
iterable[Symbol.iterator] = function () {
|
| 149 |
+
return testIterator1;
|
| 150 |
+
};
|
| 151 |
+
|
| 152 |
+
var iterator = concat(iterable);
|
| 153 |
+
|
| 154 |
+
var iterResult = iterator.next();
|
| 155 |
+
|
| 156 |
+
s2t.equal(iterResult.done, false);
|
| 157 |
+
s2t.equal(iterResult.value, 123);
|
| 158 |
+
|
| 159 |
+
s2t.notEqual(iterResult, oldIterResult);
|
| 160 |
+
|
| 161 |
+
s2t.end();
|
| 162 |
+
});
|
| 163 |
+
|
| 164 |
+
st.test('test262: test/built-ins/Iterator/concat/get-iterator-method-only-once', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 165 |
+
var iteratorGets = 0;
|
| 166 |
+
var iteratorCalls = 0;
|
| 167 |
+
var array = [1, 2, 3];
|
| 168 |
+
|
| 169 |
+
function CountingIterable() {}
|
| 170 |
+
Object.defineProperty(
|
| 171 |
+
CountingIterable.prototype,
|
| 172 |
+
Symbol.iterator,
|
| 173 |
+
{
|
| 174 |
+
get: function () {
|
| 175 |
+
iteratorGets += 1;
|
| 176 |
+
|
| 177 |
+
return function () {
|
| 178 |
+
iteratorCalls += 1;
|
| 179 |
+
return array[Symbol.iterator]();
|
| 180 |
+
};
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
);
|
| 184 |
+
|
| 185 |
+
var iterable = new CountingIterable();
|
| 186 |
+
|
| 187 |
+
s2t.equal(iteratorGets, 0);
|
| 188 |
+
s2t.equal(iteratorCalls, 0);
|
| 189 |
+
|
| 190 |
+
var iter = concat(iterable);
|
| 191 |
+
|
| 192 |
+
s2t.equal(iteratorGets, 1);
|
| 193 |
+
s2t.equal(iteratorCalls, 0);
|
| 194 |
+
|
| 195 |
+
testIterator(iter, array, s2t, 'iterating over the iterator calls the iterator function once');
|
| 196 |
+
|
| 197 |
+
s2t.equal(iteratorGets, 1);
|
| 198 |
+
s2t.equal(iteratorCalls, 1);
|
| 199 |
+
|
| 200 |
+
s2t.end();
|
| 201 |
+
});
|
| 202 |
+
|
| 203 |
+
st.test('test262: test/built-ins/Iterator/concat/get-iterator-method-throws', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 204 |
+
var iterable = {};
|
| 205 |
+
Object.defineProperty(iterable, Symbol.iterator, {
|
| 206 |
+
get: function () {
|
| 207 |
+
throw new EvalError();
|
| 208 |
+
}
|
| 209 |
+
});
|
| 210 |
+
|
| 211 |
+
s2t['throws'](function () { concat(iterable); }, EvalError);
|
| 212 |
+
|
| 213 |
+
s2t.end();
|
| 214 |
+
});
|
| 215 |
+
|
| 216 |
+
st.test('test262: test/built-ins/Iterator/concat/inner-iterator-created-in-order', function (s2t) {
|
| 217 |
+
var calledIterator = [];
|
| 218 |
+
|
| 219 |
+
var iterable1 = {};
|
| 220 |
+
iterable1[Symbol.iterator] = function () {
|
| 221 |
+
calledIterator.push('iterable1');
|
| 222 |
+
return [1][Symbol.iterator]();
|
| 223 |
+
};
|
| 224 |
+
|
| 225 |
+
var iterable2 = {};
|
| 226 |
+
iterable2[Symbol.iterator] = function () {
|
| 227 |
+
calledIterator.push('iterable2');
|
| 228 |
+
return [2][Symbol.iterator]();
|
| 229 |
+
};
|
| 230 |
+
|
| 231 |
+
var iterator = concat(iterable1, iterable2);
|
| 232 |
+
|
| 233 |
+
s2t.deepEqual(calledIterator, []);
|
| 234 |
+
|
| 235 |
+
s2t.deepEqual(iterator.next(), { done: false, value: 1 });
|
| 236 |
+
|
| 237 |
+
s2t.deepEqual(calledIterator, ['iterable1']);
|
| 238 |
+
|
| 239 |
+
s2t.deepEqual(iterator.next(), { done: false, value: 2 });
|
| 240 |
+
|
| 241 |
+
s2t.deepEqual(calledIterator, ['iterable1', 'iterable2']);
|
| 242 |
+
|
| 243 |
+
s2t.end();
|
| 244 |
+
});
|
| 245 |
+
|
| 246 |
+
st.test('test262: test/built-ins/Iterator/concat/next-method-called-with-zero-arguments', function (s2t) {
|
| 247 |
+
var nextCalled = 0;
|
| 248 |
+
|
| 249 |
+
var testIterator1 = {
|
| 250 |
+
next: function () {
|
| 251 |
+
nextCalled += 1;
|
| 252 |
+
s2t.equal(arguments.length, 0);
|
| 253 |
+
|
| 254 |
+
return {
|
| 255 |
+
done: false,
|
| 256 |
+
value: 0
|
| 257 |
+
};
|
| 258 |
+
}
|
| 259 |
+
};
|
| 260 |
+
|
| 261 |
+
var iterable = {};
|
| 262 |
+
iterable[Symbol.iterator] = function () {
|
| 263 |
+
return testIterator1;
|
| 264 |
+
};
|
| 265 |
+
|
| 266 |
+
var iterator = concat(iterable);
|
| 267 |
+
s2t.equal(nextCalled, 0);
|
| 268 |
+
|
| 269 |
+
iterator.next();
|
| 270 |
+
s2t.equal(nextCalled, 1);
|
| 271 |
+
|
| 272 |
+
iterator.next(1);
|
| 273 |
+
s2t.equal(nextCalled, 2);
|
| 274 |
+
|
| 275 |
+
iterator.next(1, 2);
|
| 276 |
+
s2t.equal(nextCalled, 3);
|
| 277 |
+
|
| 278 |
+
s2t.end();
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
st.test('test262: test/built-ins/Iterator/concat/next-method-returns-non-object', function (s2t) {
|
| 282 |
+
var nonObjectIterator = {
|
| 283 |
+
next: function () {
|
| 284 |
+
return null;
|
| 285 |
+
}
|
| 286 |
+
};
|
| 287 |
+
|
| 288 |
+
var iterable = {};
|
| 289 |
+
iterable[Symbol.iterator] = function () {
|
| 290 |
+
return nonObjectIterator;
|
| 291 |
+
};
|
| 292 |
+
|
| 293 |
+
var iterator = concat(iterable);
|
| 294 |
+
|
| 295 |
+
s2t['throws'](function () { iterator.next(); }, TypeError);
|
| 296 |
+
|
| 297 |
+
s2t.end();
|
| 298 |
+
});
|
| 299 |
+
|
| 300 |
+
st.test('test262: test/built-ins/Iterator/concat/next-method-returns-throwing-done', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 301 |
+
var throwingIterator = {
|
| 302 |
+
next: function () {
|
| 303 |
+
var result = { done: null, value: 1 };
|
| 304 |
+
Object.defineProperty(result, 'done', {
|
| 305 |
+
get: function () {
|
| 306 |
+
throw new EvalError();
|
| 307 |
+
}
|
| 308 |
+
});
|
| 309 |
+
return result;
|
| 310 |
+
},
|
| 311 |
+
'return': function () {
|
| 312 |
+
throw new Error();
|
| 313 |
+
}
|
| 314 |
+
};
|
| 315 |
+
|
| 316 |
+
var iterable = {};
|
| 317 |
+
iterable[Symbol.iterator] = function () {
|
| 318 |
+
return throwingIterator;
|
| 319 |
+
};
|
| 320 |
+
|
| 321 |
+
var iterator = concat(iterable);
|
| 322 |
+
|
| 323 |
+
s2t['throws'](function () { iterator.next(); }, EvalError);
|
| 324 |
+
|
| 325 |
+
s2t.end();
|
| 326 |
+
});
|
| 327 |
+
|
| 328 |
+
st.test('test262: test/built-ins/Iterator/concat/next-method-returns-throwing-value-done', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 329 |
+
function ReturnCalledError() {}
|
| 330 |
+
function ValueGetterError() {}
|
| 331 |
+
|
| 332 |
+
var throwingIterator = {
|
| 333 |
+
next: function () {
|
| 334 |
+
var result = { value: null, done: true };
|
| 335 |
+
Object.defineProperty(result, 'value', {
|
| 336 |
+
get: function () {
|
| 337 |
+
throw new ValueGetterError();
|
| 338 |
+
}
|
| 339 |
+
});
|
| 340 |
+
return result;
|
| 341 |
+
},
|
| 342 |
+
'return': function () {
|
| 343 |
+
throw new ReturnCalledError();
|
| 344 |
+
}
|
| 345 |
+
};
|
| 346 |
+
|
| 347 |
+
var iterable = {};
|
| 348 |
+
iterable[Symbol.iterator] = function () {
|
| 349 |
+
return throwingIterator;
|
| 350 |
+
};
|
| 351 |
+
|
| 352 |
+
var iterator = concat(iterable);
|
| 353 |
+
|
| 354 |
+
var iterResult = iterator.next();
|
| 355 |
+
|
| 356 |
+
s2t.equal(iterResult.done, true);
|
| 357 |
+
s2t.equal(iterResult.value, undefined);
|
| 358 |
+
|
| 359 |
+
s2t.end();
|
| 360 |
+
});
|
| 361 |
+
|
| 362 |
+
st.test('test262: test/built-ins/Iterator/concat/next-method-returns-throwing-value', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 363 |
+
var throwingIterator = {
|
| 364 |
+
next: function () {
|
| 365 |
+
var result = { value: null, done: false };
|
| 366 |
+
Object.defineProperty(result, 'value', {
|
| 367 |
+
get: function () {
|
| 368 |
+
throw new EvalError();
|
| 369 |
+
}
|
| 370 |
+
});
|
| 371 |
+
return result;
|
| 372 |
+
},
|
| 373 |
+
'return': function () {
|
| 374 |
+
throw new Error();
|
| 375 |
+
}
|
| 376 |
+
};
|
| 377 |
+
|
| 378 |
+
var iterable = {};
|
| 379 |
+
iterable[Symbol.iterator] = function () {
|
| 380 |
+
return throwingIterator;
|
| 381 |
+
};
|
| 382 |
+
|
| 383 |
+
var iterator = concat(iterable);
|
| 384 |
+
|
| 385 |
+
s2t['throws'](function () { iterator.next(); }, EvalError);
|
| 386 |
+
|
| 387 |
+
s2t.end();
|
| 388 |
+
});
|
| 389 |
+
|
| 390 |
+
st.test('test262: test/built-ins/Iterator/concat/next-method-throws', function (s2t) {
|
| 391 |
+
var throwingIterator = {
|
| 392 |
+
next: function () {
|
| 393 |
+
throw new EvalError();
|
| 394 |
+
}
|
| 395 |
+
};
|
| 396 |
+
|
| 397 |
+
var iterable = {};
|
| 398 |
+
iterable[Symbol.iterator] = function () {
|
| 399 |
+
return throwingIterator;
|
| 400 |
+
};
|
| 401 |
+
|
| 402 |
+
var iterator = concat(iterable);
|
| 403 |
+
|
| 404 |
+
s2t['throws'](function () { iterator.next(); }, EvalError);
|
| 405 |
+
|
| 406 |
+
s2t.end();
|
| 407 |
+
});
|
| 408 |
+
|
| 409 |
+
st.test('test262: test/built-ins/Iterator/concat/return-is-not-forwarded-after-exhaustion', function (s2t) {
|
| 410 |
+
var testIterator1 = {
|
| 411 |
+
next: function () {
|
| 412 |
+
return {
|
| 413 |
+
done: true,
|
| 414 |
+
value: undefined
|
| 415 |
+
};
|
| 416 |
+
},
|
| 417 |
+
'return': function () {
|
| 418 |
+
throw new EvalError();
|
| 419 |
+
}
|
| 420 |
+
};
|
| 421 |
+
|
| 422 |
+
var iterable = {};
|
| 423 |
+
iterable[Symbol.iterator] = function () {
|
| 424 |
+
return testIterator1;
|
| 425 |
+
};
|
| 426 |
+
|
| 427 |
+
var iterator = concat(iterable);
|
| 428 |
+
iterator.next();
|
| 429 |
+
iterator['return']();
|
| 430 |
+
|
| 431 |
+
s2t.end();
|
| 432 |
+
});
|
| 433 |
+
|
| 434 |
+
t.test('test262: test/built-ins/Iterator/concat/return-is-not-forwarded-before-initial-start', function (s2t) {
|
| 435 |
+
var testIterator1 = {
|
| 436 |
+
next: function () {
|
| 437 |
+
return {
|
| 438 |
+
done: false,
|
| 439 |
+
value: 1
|
| 440 |
+
};
|
| 441 |
+
},
|
| 442 |
+
'return': function () {
|
| 443 |
+
throw new EvalError();
|
| 444 |
+
}
|
| 445 |
+
};
|
| 446 |
+
|
| 447 |
+
var iterable = {};
|
| 448 |
+
iterable[Symbol.iterator] = function () {
|
| 449 |
+
return testIterator1;
|
| 450 |
+
};
|
| 451 |
+
|
| 452 |
+
var iterator = concat(iterable);
|
| 453 |
+
iterator['return']();
|
| 454 |
+
iterator.next();
|
| 455 |
+
iterator['return']();
|
| 456 |
+
|
| 457 |
+
s2t.end();
|
| 458 |
+
});
|
| 459 |
+
|
| 460 |
+
st.test('test262: test/built-ins/Iterator/concat/return-method-called-with-zero-arguments', function (s2t) {
|
| 461 |
+
var returnCalled = 0;
|
| 462 |
+
|
| 463 |
+
var testIterator1 = {
|
| 464 |
+
next: function () {
|
| 465 |
+
return { done: false };
|
| 466 |
+
},
|
| 467 |
+
'return': function () {
|
| 468 |
+
returnCalled += 1;
|
| 469 |
+
s2t.equal(arguments.length, 0);
|
| 470 |
+
return { done: true };
|
| 471 |
+
}
|
| 472 |
+
};
|
| 473 |
+
|
| 474 |
+
var iterable = {};
|
| 475 |
+
iterable[Symbol.iterator] = function () {
|
| 476 |
+
return testIterator1;
|
| 477 |
+
};
|
| 478 |
+
|
| 479 |
+
var iterator;
|
| 480 |
+
|
| 481 |
+
// Call with zero arguments.
|
| 482 |
+
iterator = concat(iterable);
|
| 483 |
+
iterator.next();
|
| 484 |
+
s2t.equal(returnCalled, 0);
|
| 485 |
+
|
| 486 |
+
iterator['return']();
|
| 487 |
+
s2t.equal(returnCalled, 1);
|
| 488 |
+
|
| 489 |
+
// Call with one argument.
|
| 490 |
+
iterator = concat(iterable);
|
| 491 |
+
iterator.next();
|
| 492 |
+
s2t.equal(returnCalled, 1);
|
| 493 |
+
|
| 494 |
+
iterator['return'](1);
|
| 495 |
+
s2t.equal(returnCalled, 2);
|
| 496 |
+
|
| 497 |
+
// Call with two arguments.
|
| 498 |
+
iterator = concat(iterable);
|
| 499 |
+
iterator.next();
|
| 500 |
+
s2t.equal(returnCalled, 2);
|
| 501 |
+
|
| 502 |
+
iterator['return'](1, 2);
|
| 503 |
+
s2t.equal(returnCalled, 3);
|
| 504 |
+
|
| 505 |
+
s2t.end();
|
| 506 |
+
});
|
| 507 |
+
|
| 508 |
+
st.test('test262: test/built-ins/Iterator/concat/throws-typeerror-when-generator-is-running-next', function (s2t) {
|
| 509 |
+
var enterCount = 0;
|
| 510 |
+
|
| 511 |
+
var iterator;
|
| 512 |
+
|
| 513 |
+
var testIterator1 = {
|
| 514 |
+
next: function () {
|
| 515 |
+
enterCount += 1;
|
| 516 |
+
iterator.next();
|
| 517 |
+
return { done: false };
|
| 518 |
+
}
|
| 519 |
+
};
|
| 520 |
+
|
| 521 |
+
var iterable = {};
|
| 522 |
+
iterable[Symbol.iterator] = function () {
|
| 523 |
+
return testIterator1;
|
| 524 |
+
};
|
| 525 |
+
|
| 526 |
+
iterator = concat(iterable);
|
| 527 |
+
|
| 528 |
+
s2t.equal(enterCount, 0);
|
| 529 |
+
|
| 530 |
+
s2t['throws'](function () { iterator.next(); }, TypeError);
|
| 531 |
+
|
| 532 |
+
s2t.equal(enterCount, 1);
|
| 533 |
+
|
| 534 |
+
s2t.end();
|
| 535 |
+
});
|
| 536 |
+
|
| 537 |
+
st.test('test262: test/built-ins/Iterator/concat/result-is-iterator', function (s2t) {
|
| 538 |
+
var iter = concat();
|
| 539 |
+
s2t.equal(typeof iter.next, 'function', 'concat() result has next method');
|
| 540 |
+
s2t.equal(typeof iter[Symbol.iterator], 'function', 'concat() result has Symbol.iterator');
|
| 541 |
+
s2t.equal(iter[Symbol.iterator](), iter, 'concat() result Symbol.iterator returns itself');
|
| 542 |
+
|
| 543 |
+
var customIter = { next: function () { return { done: true, value: undefined }; } };
|
| 544 |
+
var iterable = {};
|
| 545 |
+
iterable[Symbol.iterator] = function () { return customIter; };
|
| 546 |
+
iter = concat(iterable);
|
| 547 |
+
s2t.equal(typeof iter.next, 'function', 'concat(iterable) result has next method');
|
| 548 |
+
s2t.equal(typeof iter[Symbol.iterator], 'function', 'concat(iterable) result has Symbol.iterator');
|
| 549 |
+
s2t.equal(iter[Symbol.iterator](), iter, 'concat(iterable) result Symbol.iterator returns itself');
|
| 550 |
+
|
| 551 |
+
s2t.end();
|
| 552 |
+
});
|
| 553 |
+
|
| 554 |
+
st.test('test262: test/built-ins/Iterator/concat/single-argument', function (s2t) {
|
| 555 |
+
var array = [1, 2, 3];
|
| 556 |
+
var iterator = concat(array);
|
| 557 |
+
|
| 558 |
+
for (var i = 0; i < array.length; i += 1) {
|
| 559 |
+
var iterResult = iterator.next();
|
| 560 |
+
s2t.equal(iterResult.done, false, 'not done at index ' + i);
|
| 561 |
+
s2t.equal(iterResult.value, array[i], 'correct value at index ' + i);
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
var finalResult = iterator.next();
|
| 565 |
+
s2t.equal(finalResult.done, true, 'done after all values');
|
| 566 |
+
s2t.equal(finalResult.value, undefined, 'value is undefined when done');
|
| 567 |
+
|
| 568 |
+
s2t.end();
|
| 569 |
+
});
|
| 570 |
+
|
| 571 |
+
st.test('test262: test/built-ins/Iterator/concat/many-arguments', function (s2t) {
|
| 572 |
+
var iterables = [
|
| 573 |
+
[],
|
| 574 |
+
[1],
|
| 575 |
+
[2, 3],
|
| 576 |
+
[4, 5, 6],
|
| 577 |
+
[7, 8, 9, 10]
|
| 578 |
+
];
|
| 579 |
+
|
| 580 |
+
var iterator = concat(iterables[0], iterables[1], iterables[2], iterables[3], iterables[4]);
|
| 581 |
+
|
| 582 |
+
var expected = [].concat(iterables[0], iterables[1], iterables[2], iterables[3], iterables[4]);
|
| 583 |
+
|
| 584 |
+
for (var i = 0; i < expected.length; i += 1) {
|
| 585 |
+
var iterResult = iterator.next();
|
| 586 |
+
s2t.equal(iterResult.done, false, 'not done at index ' + i);
|
| 587 |
+
s2t.equal(iterResult.value, expected[i], 'correct value at index ' + i);
|
| 588 |
+
}
|
| 589 |
+
|
| 590 |
+
var finalResult = iterator.next();
|
| 591 |
+
s2t.equal(finalResult.done, true, 'done after all values');
|
| 592 |
+
s2t.equal(finalResult.value, undefined, 'value is undefined when done');
|
| 593 |
+
|
| 594 |
+
s2t.end();
|
| 595 |
+
});
|
| 596 |
+
|
| 597 |
+
st.test('test262: test/built-ins/Iterator/concat/zero-arguments', function (s2t) {
|
| 598 |
+
var iterator = concat();
|
| 599 |
+
|
| 600 |
+
var iterResult = iterator.next();
|
| 601 |
+
s2t.equal(iterResult.done, true, 'done immediately with zero arguments');
|
| 602 |
+
s2t.equal(iterResult.value, undefined, 'value is undefined');
|
| 603 |
+
|
| 604 |
+
s2t.end();
|
| 605 |
+
});
|
| 606 |
+
|
| 607 |
+
st.test('test262: test/built-ins/Iterator/concat/return-is-forwarded', function (s2t) {
|
| 608 |
+
var returnCount = 0;
|
| 609 |
+
|
| 610 |
+
var testIterator1 = {
|
| 611 |
+
next: function () {
|
| 612 |
+
return { done: false, value: 1 };
|
| 613 |
+
},
|
| 614 |
+
'return': function () {
|
| 615 |
+
returnCount += 1;
|
| 616 |
+
return { done: true, value: undefined };
|
| 617 |
+
}
|
| 618 |
+
};
|
| 619 |
+
|
| 620 |
+
var iterable = {};
|
| 621 |
+
iterable[Symbol.iterator] = function () {
|
| 622 |
+
return testIterator1;
|
| 623 |
+
};
|
| 624 |
+
|
| 625 |
+
var iterator = concat(iterable);
|
| 626 |
+
|
| 627 |
+
s2t.equal(returnCount, 0, 'return not called before next()');
|
| 628 |
+
|
| 629 |
+
iterator.next();
|
| 630 |
+
|
| 631 |
+
s2t.equal(returnCount, 0, 'return not called after next()');
|
| 632 |
+
|
| 633 |
+
iterator['return']();
|
| 634 |
+
|
| 635 |
+
s2t.equal(returnCount, 1, 'return called once after iterator.return()');
|
| 636 |
+
|
| 637 |
+
// Subsequent return() calls should not forward again
|
| 638 |
+
iterator['return']();
|
| 639 |
+
|
| 640 |
+
s2t.equal(returnCount, 1, 'return not called again on subsequent return()');
|
| 641 |
+
|
| 642 |
+
s2t.end();
|
| 643 |
+
});
|
| 644 |
+
|
| 645 |
+
st.test('test262: test/built-ins/Iterator/concat/throws-typeerror-when-generator-is-running-return', function (s2t) {
|
| 646 |
+
var enterCount = 0;
|
| 647 |
+
var iterator;
|
| 648 |
+
|
| 649 |
+
var reentrantTestIterator = {
|
| 650 |
+
next: function () {
|
| 651 |
+
return { done: false };
|
| 652 |
+
},
|
| 653 |
+
'return': function () {
|
| 654 |
+
enterCount += 1;
|
| 655 |
+
iterator['return'](); // re-entrant call
|
| 656 |
+
return { done: false };
|
| 657 |
+
}
|
| 658 |
+
};
|
| 659 |
+
|
| 660 |
+
var iterable = {};
|
| 661 |
+
iterable[Symbol.iterator] = function () {
|
| 662 |
+
return reentrantTestIterator;
|
| 663 |
+
};
|
| 664 |
+
|
| 665 |
+
iterator = concat(iterable);
|
| 666 |
+
|
| 667 |
+
iterator.next();
|
| 668 |
+
|
| 669 |
+
s2t.equal(enterCount, 0, 'return not entered before calling return()');
|
| 670 |
+
|
| 671 |
+
s2t['throws'](
|
| 672 |
+
function () { iterator['return'](); },
|
| 673 |
+
TypeError,
|
| 674 |
+
'throws TypeError when generator is running during return()'
|
| 675 |
+
);
|
| 676 |
+
|
| 677 |
+
s2t.equal(enterCount, 1, 'return entered exactly once before throwing');
|
| 678 |
+
|
| 679 |
+
s2t.end();
|
| 680 |
+
});
|
| 681 |
+
|
| 682 |
+
st.end();
|
| 683 |
+
});
|
| 684 |
+
},
|
| 685 |
+
index: function () {
|
| 686 |
+
test('Iterator.concat: index', function (t) {
|
| 687 |
+
module.exports.tests(index, 'Iterator.concat', t);
|
| 688 |
+
|
| 689 |
+
t.end();
|
| 690 |
+
});
|
| 691 |
+
},
|
| 692 |
+
implementation: function () {
|
| 693 |
+
test('Iterator.concat: implementation', function (t) {
|
| 694 |
+
module.exports.tests(impl, 'Iterator.concat', t);
|
| 695 |
+
|
| 696 |
+
t.end();
|
| 697 |
+
});
|
| 698 |
+
},
|
| 699 |
+
shimmed: function () {
|
| 700 |
+
test('Iterator.concat: shimmed', function (t) {
|
| 701 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 702 |
+
st.equal(Iterator.concat.name, 'concat', 'Iterator.concat has name "concat"');
|
| 703 |
+
st.end();
|
| 704 |
+
});
|
| 705 |
+
|
| 706 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 707 |
+
et.equal(false, isEnumerable.call(Iterator, 'concat'), 'Iterator.concat is not enumerable');
|
| 708 |
+
et.end();
|
| 709 |
+
});
|
| 710 |
+
|
| 711 |
+
t.equal(Iterator.concat.length, 0, 'Iterator.concat has length 0');
|
| 712 |
+
|
| 713 |
+
module.exports.tests(callBind(Iterator.concat, Iterator), 'Iterator.concat', t);
|
| 714 |
+
|
| 715 |
+
t.end();
|
| 716 |
+
});
|
| 717 |
+
}
|
| 718 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.from.js
ADDED
|
@@ -0,0 +1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functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasProto = require('has-proto')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 13 |
+
var mockProperty = require('mock-property');
|
| 14 |
+
|
| 15 |
+
var index = require('../Iterator.from');
|
| 16 |
+
var impl = require('../Iterator.from/implementation');
|
| 17 |
+
|
| 18 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 19 |
+
|
| 20 |
+
var testIterator = require('./helpers/testIterator');
|
| 21 |
+
|
| 22 |
+
var $Iterator = require('../Iterator/implementation');
|
| 23 |
+
var iterProto = require('iterator.prototype');
|
| 24 |
+
|
| 25 |
+
var getCodePoints = function getCodePoints(str) {
|
| 26 |
+
var chars = [];
|
| 27 |
+
for (var i = 0; i < str.length; i++) {
|
| 28 |
+
var c1 = str.charCodeAt(i);
|
| 29 |
+
if (c1 >= 0xD800 && c1 < 0xDC00 && i + 1 < str.length) {
|
| 30 |
+
var c2 = str.charCodeAt(i + 1);
|
| 31 |
+
if (c2 >= 0xDC00 && c2 < 0xE000) {
|
| 32 |
+
chars.push(str.charAt(i) + str.charAt(i + 1));
|
| 33 |
+
i += 1;
|
| 34 |
+
continue; // eslint-disable-line no-continue, no-restricted-syntax
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
chars.push(str.charAt(i));
|
| 38 |
+
}
|
| 39 |
+
return chars;
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
module.exports = {
|
| 43 |
+
tests: function (from, name, t) {
|
| 44 |
+
t['throws'](
|
| 45 |
+
function () { return new from(); }, // eslint-disable-line new-cap
|
| 46 |
+
TypeError,
|
| 47 |
+
'`' + name + '` itself is not a constructor'
|
| 48 |
+
);
|
| 49 |
+
t['throws'](
|
| 50 |
+
function () { return new from({}); }, // eslint-disable-line new-cap
|
| 51 |
+
TypeError,
|
| 52 |
+
'`' + name + '` itself is not a constructor, with an argument'
|
| 53 |
+
);
|
| 54 |
+
|
| 55 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 56 |
+
if (typeof nonIterator !== 'string') {
|
| 57 |
+
t['throws'](
|
| 58 |
+
function () { from(nonIterator).next(); },
|
| 59 |
+
TypeError,
|
| 60 |
+
debug(nonIterator) + ' is not an iterable Object'
|
| 61 |
+
);
|
| 62 |
+
}
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 66 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 67 |
+
var badIterable = {};
|
| 68 |
+
badIterable[Symbol.iterator] = nonFunction;
|
| 69 |
+
st['throws'](
|
| 70 |
+
function () { from(badIterable).next(); },
|
| 71 |
+
TypeError,
|
| 72 |
+
debug(badIterable) + ' is not a function'
|
| 73 |
+
);
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
// st['throws'](
|
| 77 |
+
// function () { return new from([]); }, // eslint-disable-line new-cap
|
| 78 |
+
// RangeError,
|
| 79 |
+
// '`' + name + '` iterator is not a constructor'
|
| 80 |
+
// );
|
| 81 |
+
|
| 82 |
+
forEach(v.strings, function (string) {
|
| 83 |
+
var stringIt = from(string);
|
| 84 |
+
testIterator(stringIt, getCodePoints(string), st, 'string iterator: ' + debug(string));
|
| 85 |
+
});
|
| 86 |
+
|
| 87 |
+
var arrayIt = from([1, 2, 3]);
|
| 88 |
+
st.equal(typeof arrayIt.next, 'function', 'has a `next` function');
|
| 89 |
+
|
| 90 |
+
st.test('__proto__ is Iterator.prototype', { skip: !hasProto }, function (s2t) {
|
| 91 |
+
var fakeIterator = {
|
| 92 |
+
__proto__: iterProto,
|
| 93 |
+
next: function () {}
|
| 94 |
+
};
|
| 95 |
+
s2t.ok(fakeIterator instanceof $Iterator, 'is an instanceof Iterator');
|
| 96 |
+
s2t.equal(typeof fakeIterator.next, 'function', 'fake iterator `.next` is a function');
|
| 97 |
+
s2t.equal(from(fakeIterator), fakeIterator, 'returns input when it is an instanceof Iterator');
|
| 98 |
+
|
| 99 |
+
s2t.end();
|
| 100 |
+
});
|
| 101 |
+
|
| 102 |
+
st.test('real iterators', { skip: !hasSymbols }, function (s2t) {
|
| 103 |
+
var iter = [][Symbol.iterator]();
|
| 104 |
+
// eslint-disable-next-line no-proto
|
| 105 |
+
var arrayIterHasIterProto = hasProto && iter.__proto__.__proto__ !== Object.prototype;
|
| 106 |
+
s2t.equal(
|
| 107 |
+
from(iter),
|
| 108 |
+
iter,
|
| 109 |
+
'array iterator becomes itself',
|
| 110 |
+
{ skip: !arrayIterHasIterProto && 'node 0.12 - 3 do not have Iterator.prototype in the proto chains' }
|
| 111 |
+
);
|
| 112 |
+
|
| 113 |
+
s2t.end();
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
st.test('observability in a replaced String iterator', function (s2t) {
|
| 117 |
+
var originalStringIterator = String.prototype[Symbol.iterator];
|
| 118 |
+
var observedType;
|
| 119 |
+
s2t.teardown(mockProperty(String.prototype, Symbol.iterator, {
|
| 120 |
+
get: function () {
|
| 121 |
+
'use strict'; // eslint-disable-line strict, lines-around-directive
|
| 122 |
+
|
| 123 |
+
observedType = typeof this;
|
| 124 |
+
return originalStringIterator;
|
| 125 |
+
}
|
| 126 |
+
}));
|
| 127 |
+
|
| 128 |
+
from('');
|
| 129 |
+
s2t.equal(observedType, 'string', 'string primitive -> primitive receiver in Symbol.iterator getter');
|
| 130 |
+
from(Object(''));
|
| 131 |
+
s2t.equal(observedType, 'object', 'boxed string -> boxed string in Symbol.iterator getter');
|
| 132 |
+
|
| 133 |
+
s2t.end();
|
| 134 |
+
});
|
| 135 |
+
|
| 136 |
+
st.test('262: get-next-method-only-once', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 137 |
+
var nextGets = 0;
|
| 138 |
+
var testIter = {
|
| 139 |
+
next: function () {
|
| 140 |
+
return { done: true, value: undefined };
|
| 141 |
+
}
|
| 142 |
+
};
|
| 143 |
+
Object.defineProperty(testIter, 'next', {
|
| 144 |
+
get: function () {
|
| 145 |
+
nextGets += 1;
|
| 146 |
+
return function () {
|
| 147 |
+
return { done: true, value: undefined };
|
| 148 |
+
};
|
| 149 |
+
}
|
| 150 |
+
});
|
| 151 |
+
|
| 152 |
+
var iter = from(testIter);
|
| 153 |
+
s2t.equal(nextGets, 1, 'next retrieved once on creation');
|
| 154 |
+
iter.next();
|
| 155 |
+
s2t.equal(nextGets, 1, 'next not retrieved again on next()');
|
| 156 |
+
iter.next();
|
| 157 |
+
s2t.equal(nextGets, 1, 'next still not retrieved again');
|
| 158 |
+
|
| 159 |
+
s2t.end();
|
| 160 |
+
});
|
| 161 |
+
|
| 162 |
+
st.test('262: get-next-method-throws', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 163 |
+
var testIter = {};
|
| 164 |
+
Object.defineProperty(testIter, 'next', {
|
| 165 |
+
get: function () {
|
| 166 |
+
throw new EvalError('next getter threw');
|
| 167 |
+
}
|
| 168 |
+
});
|
| 169 |
+
|
| 170 |
+
s2t['throws'](
|
| 171 |
+
function () { from(testIter); },
|
| 172 |
+
EvalError,
|
| 173 |
+
'throws when getting next throws'
|
| 174 |
+
);
|
| 175 |
+
|
| 176 |
+
s2t.end();
|
| 177 |
+
});
|
| 178 |
+
|
| 179 |
+
st.test('262: iterable-to-iterator-fallback', function (s2t) {
|
| 180 |
+
// When Symbol.iterator is null/undefined, treat object as iterator
|
| 181 |
+
var iteratorObj = {
|
| 182 |
+
next: function () {
|
| 183 |
+
return { done: true, value: undefined };
|
| 184 |
+
}
|
| 185 |
+
};
|
| 186 |
+
iteratorObj[Symbol.iterator] = null;
|
| 187 |
+
var iter1 = from(iteratorObj);
|
| 188 |
+
s2t.equal(typeof iter1.next, 'function', 'iterator with null Symbol.iterator is treated as iterator');
|
| 189 |
+
|
| 190 |
+
var iteratorObj2 = {
|
| 191 |
+
next: function () {
|
| 192 |
+
return { done: true, value: undefined };
|
| 193 |
+
}
|
| 194 |
+
};
|
| 195 |
+
iteratorObj2[Symbol.iterator] = undefined;
|
| 196 |
+
var iter2 = from(iteratorObj2);
|
| 197 |
+
s2t.equal(typeof iter2.next, 'function', 'iterator with undefined Symbol.iterator is treated as iterator');
|
| 198 |
+
|
| 199 |
+
s2t.end();
|
| 200 |
+
});
|
| 201 |
+
|
| 202 |
+
st.test('262: return-is-forwarded', function (s2t) {
|
| 203 |
+
var returnCalls = 0;
|
| 204 |
+
var testIter = {
|
| 205 |
+
next: function () {
|
| 206 |
+
return { done: false, value: 1 };
|
| 207 |
+
},
|
| 208 |
+
'return': function () {
|
| 209 |
+
returnCalls += 1;
|
| 210 |
+
return { done: true, value: undefined };
|
| 211 |
+
}
|
| 212 |
+
};
|
| 213 |
+
|
| 214 |
+
var iter = from(testIter);
|
| 215 |
+
iter.next();
|
| 216 |
+
s2t.equal(returnCalls, 0, 'return not called before calling return()');
|
| 217 |
+
iter['return']();
|
| 218 |
+
s2t.equal(returnCalls, 1, 'return called once after return()');
|
| 219 |
+
|
| 220 |
+
s2t.end();
|
| 221 |
+
});
|
| 222 |
+
|
| 223 |
+
st.test('262: return-method-returns-iterator-result', function (s2t) {
|
| 224 |
+
// When base iterator has no return method, wrapper's return() returns { done: true, value: undefined }
|
| 225 |
+
var testIter = {
|
| 226 |
+
next: function () {
|
| 227 |
+
return { done: false, value: 1 };
|
| 228 |
+
}
|
| 229 |
+
};
|
| 230 |
+
|
| 231 |
+
var iter = from(testIter);
|
| 232 |
+
iter.next();
|
| 233 |
+
var result = iter['return']();
|
| 234 |
+
s2t.equal(result.done, true, 'done is true');
|
| 235 |
+
s2t.equal(result.value, undefined, 'value is undefined');
|
| 236 |
+
|
| 237 |
+
s2t.end();
|
| 238 |
+
});
|
| 239 |
+
|
| 240 |
+
st.test('262: get-return-method-throws', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 241 |
+
var testIter = {
|
| 242 |
+
next: function () {
|
| 243 |
+
return { done: false, value: 1 };
|
| 244 |
+
}
|
| 245 |
+
};
|
| 246 |
+
Object.defineProperty(testIter, 'return', {
|
| 247 |
+
get: function () {
|
| 248 |
+
throw new SyntaxError('return getter threw');
|
| 249 |
+
}
|
| 250 |
+
});
|
| 251 |
+
|
| 252 |
+
var iter = from(testIter);
|
| 253 |
+
iter.next();
|
| 254 |
+
s2t['throws'](
|
| 255 |
+
function () { iter['return'](); },
|
| 256 |
+
SyntaxError,
|
| 257 |
+
'throws when getting return throws'
|
| 258 |
+
);
|
| 259 |
+
|
| 260 |
+
s2t.end();
|
| 261 |
+
});
|
| 262 |
+
|
| 263 |
+
st.test('262: supports-iterator', function (s2t) {
|
| 264 |
+
// Non-iterable iterator objects (no Symbol.iterator, but has next)
|
| 265 |
+
var plainIterator = {
|
| 266 |
+
next: function () {
|
| 267 |
+
return { done: true, value: 42 };
|
| 268 |
+
}
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
var iter = from(plainIterator);
|
| 272 |
+
s2t.equal(typeof iter.next, 'function', 'wrapped iterator has next method');
|
| 273 |
+
var result = iter.next();
|
| 274 |
+
s2t.equal(result.done, true, 'done is true');
|
| 275 |
+
s2t.equal(result.value, 42, 'value is passed through');
|
| 276 |
+
|
| 277 |
+
s2t.end();
|
| 278 |
+
});
|
| 279 |
+
|
| 280 |
+
st.test('262: supports-iterable', function (s2t) {
|
| 281 |
+
// Iterable objects work
|
| 282 |
+
var arr = [1, 2, 3];
|
| 283 |
+
testIterator(from(arr), [1, 2, 3], s2t, 'array iterable');
|
| 284 |
+
|
| 285 |
+
s2t.end();
|
| 286 |
+
});
|
| 287 |
+
|
| 288 |
+
st.end();
|
| 289 |
+
});
|
| 290 |
+
},
|
| 291 |
+
index: function () {
|
| 292 |
+
test('Iterator.from: index', function (t) {
|
| 293 |
+
module.exports.tests(index, 'Iterator.from', t);
|
| 294 |
+
|
| 295 |
+
t.end();
|
| 296 |
+
});
|
| 297 |
+
},
|
| 298 |
+
implementation: function () {
|
| 299 |
+
test('Iterator.from: implementation', function (t) {
|
| 300 |
+
module.exports.tests(impl, 'Iterator.from', t);
|
| 301 |
+
|
| 302 |
+
t.end();
|
| 303 |
+
});
|
| 304 |
+
},
|
| 305 |
+
shimmed: function () {
|
| 306 |
+
test('Iterator.from: shimmed', function (t) {
|
| 307 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 308 |
+
st.equal(Iterator.from.name, 'from', 'Iterator.from has name "from"');
|
| 309 |
+
st.end();
|
| 310 |
+
});
|
| 311 |
+
|
| 312 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 313 |
+
et.equal(false, isEnumerable.call(Iterator, 'from'), 'Iterator.from is not enumerable');
|
| 314 |
+
et.end();
|
| 315 |
+
});
|
| 316 |
+
|
| 317 |
+
module.exports.tests(callBind(Iterator.from, Iterator), 'Iterator.from', t);
|
| 318 |
+
|
| 319 |
+
t.end();
|
| 320 |
+
});
|
| 321 |
+
}
|
| 322 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 6 |
+
|
| 7 |
+
var index = require('../Iterator');
|
| 8 |
+
var impl = require('../Iterator/implementation');
|
| 9 |
+
|
| 10 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 11 |
+
|
| 12 |
+
module.exports = {
|
| 13 |
+
tests: function (Iter, name, t) {
|
| 14 |
+
t.equal(typeof Iter, 'function', name + ' is a function');
|
| 15 |
+
|
| 16 |
+
t['throws'](
|
| 17 |
+
function () { Iter(); }, // eslint-disable-line new-cap
|
| 18 |
+
TypeError,
|
| 19 |
+
name + ' throws when Call-ed'
|
| 20 |
+
);
|
| 21 |
+
|
| 22 |
+
t['throws'](
|
| 23 |
+
function () { return new Iter(); },
|
| 24 |
+
TypeError,
|
| 25 |
+
name + ' throws when Construct-ed'
|
| 26 |
+
);
|
| 27 |
+
|
| 28 |
+
var SubIter;
|
| 29 |
+
var SubSubIter;
|
| 30 |
+
try {
|
| 31 |
+
/* eslint no-new-func: 0 */
|
| 32 |
+
SubIter = Function('Iter', 'return class SubIter extends Iter {};')(Iter);
|
| 33 |
+
SubSubIter = Function('SubIter', 'return class SubSubIter extends SubIter {};')(SubIter);
|
| 34 |
+
} catch (e) { /**/ }
|
| 35 |
+
|
| 36 |
+
t.test('class inheritance', { skip: !SubIter }, function (st) {
|
| 37 |
+
st.doesNotThrow(
|
| 38 |
+
function () { return new SubIter(); },
|
| 39 |
+
'Extending ' + name + ' does not throw when Construct-ed'
|
| 40 |
+
);
|
| 41 |
+
st.doesNotThrow(
|
| 42 |
+
function () { return new SubSubIter(); },
|
| 43 |
+
'Extending ' + name + ' twice does not throw when Construct-ed'
|
| 44 |
+
);
|
| 45 |
+
|
| 46 |
+
st.end();
|
| 47 |
+
});
|
| 48 |
+
},
|
| 49 |
+
index: function () {
|
| 50 |
+
test('Iterator: index', function (t) {
|
| 51 |
+
module.exports.tests(index, 'Iterator', t);
|
| 52 |
+
|
| 53 |
+
t.end();
|
| 54 |
+
});
|
| 55 |
+
},
|
| 56 |
+
implementation: function () {
|
| 57 |
+
test('Iterator: implementation', function (t) {
|
| 58 |
+
module.exports.tests(impl, 'Iterator', t);
|
| 59 |
+
|
| 60 |
+
t.end();
|
| 61 |
+
});
|
| 62 |
+
},
|
| 63 |
+
shimmed: function () {
|
| 64 |
+
test('Iterator: shimmed', function (t) {
|
| 65 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 66 |
+
st.equal(Iterator.name, 'Iterator', 'Iterator has name "Iterator"');
|
| 67 |
+
st.end();
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 71 |
+
et.equal(false, isEnumerable.call(global, Iterator), 'Iterator is not enumerable');
|
| 72 |
+
et.end();
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
t.test('prototype descriptor', { skip: !defineProperties.supportsDescriptors }, function (pt) {
|
| 76 |
+
var desc = Object.getOwnPropertyDescriptor(Iterator, 'prototype');
|
| 77 |
+
pt.deepEqual(
|
| 78 |
+
desc,
|
| 79 |
+
{
|
| 80 |
+
configurable: false,
|
| 81 |
+
enumerable: false,
|
| 82 |
+
value: Iterator.prototype,
|
| 83 |
+
writable: false
|
| 84 |
+
}
|
| 85 |
+
);
|
| 86 |
+
|
| 87 |
+
pt.end();
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
module.exports.tests(Iterator, 'Iterator', t);
|
| 91 |
+
|
| 92 |
+
t.end();
|
| 93 |
+
});
|
| 94 |
+
}
|
| 95 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.constructor.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
|
| 6 |
+
var Index = require('../Iterator.prototype.constructor');
|
| 7 |
+
var Impl = require('../Iterator.prototype.constructor/implementation');
|
| 8 |
+
|
| 9 |
+
var $Iterator = require('../Iterator/polyfill')();
|
| 10 |
+
|
| 11 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 12 |
+
|
| 13 |
+
module.exports = {
|
| 14 |
+
tests: function (t, constructor, name) {
|
| 15 |
+
t.equal(constructor, $Iterator, name + ' is Iterator');
|
| 16 |
+
},
|
| 17 |
+
index: function () {
|
| 18 |
+
test('Iterator.prototype.constructor: index', function (t) {
|
| 19 |
+
t.notEqual(Index, $Iterator, 'index is not Iterator itself');
|
| 20 |
+
t.equal(typeof Index, 'function', 'index is a function');
|
| 21 |
+
|
| 22 |
+
t['throws'](
|
| 23 |
+
function () { Index(); }, // eslint-disable-line new-cap
|
| 24 |
+
TypeError,
|
| 25 |
+
'index throws when Call-ed'
|
| 26 |
+
);
|
| 27 |
+
|
| 28 |
+
t['throws'](
|
| 29 |
+
function () { return new Index(); },
|
| 30 |
+
TypeError,
|
| 31 |
+
'index throws when Construct-ed'
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
t.end();
|
| 35 |
+
});
|
| 36 |
+
},
|
| 37 |
+
implementation: function () {
|
| 38 |
+
test('Iterator.prototype.constructor: implementation', function (t) {
|
| 39 |
+
t.equal(Impl, $Iterator, 'implementation is Iterator itself');
|
| 40 |
+
module.exports.tests(t, Impl, 'Iterator.prototype.constructor');
|
| 41 |
+
|
| 42 |
+
t.end();
|
| 43 |
+
});
|
| 44 |
+
},
|
| 45 |
+
shimmed: function () {
|
| 46 |
+
test('Iterator.prototype.constructor: shimmed', function (t) {
|
| 47 |
+
module.exports.tests(t, Iterator.prototype.constructor, 'Iterator.prototype.constructor');
|
| 48 |
+
|
| 49 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 50 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, 'constructor'), 'Iterator#constructor is not enumerable');
|
| 51 |
+
et.end();
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
t.end();
|
| 55 |
+
});
|
| 56 |
+
}
|
| 57 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.drop.js
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 13 |
+
var iterate = require('iterate-iterator');
|
| 14 |
+
|
| 15 |
+
var index = require('../Iterator.prototype.drop');
|
| 16 |
+
var impl = require('../Iterator.prototype.drop/implementation');
|
| 17 |
+
|
| 18 |
+
var fnName = 'drop';
|
| 19 |
+
|
| 20 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 21 |
+
|
| 22 |
+
var testIterator = require('./helpers/testIterator');
|
| 23 |
+
|
| 24 |
+
module.exports = {
|
| 25 |
+
tests: function (drop, name, t) {
|
| 26 |
+
t['throws'](
|
| 27 |
+
function () { return new drop(); }, // eslint-disable-line new-cap
|
| 28 |
+
TypeError,
|
| 29 |
+
'`' + name + '` itself is not a constructor'
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 33 |
+
t['throws'](
|
| 34 |
+
function () { iterate(drop(nonIterator, 0)); },
|
| 35 |
+
TypeError,
|
| 36 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 37 |
+
);
|
| 38 |
+
|
| 39 |
+
var badNext = { next: nonIterator };
|
| 40 |
+
t['throws'](
|
| 41 |
+
function () { iterate(drop(badNext, 0)); },
|
| 42 |
+
TypeError,
|
| 43 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 44 |
+
);
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
t.test('observable lookups', { skip: !hasPropertyDescriptors }, function (st) {
|
| 48 |
+
var effects = [];
|
| 49 |
+
|
| 50 |
+
var obj = {};
|
| 51 |
+
Object.defineProperty(obj, 'next', {
|
| 52 |
+
configurable: true,
|
| 53 |
+
enumerable: true,
|
| 54 |
+
get: function next() {
|
| 55 |
+
effects.push('get next');
|
| 56 |
+
return function () {
|
| 57 |
+
return { done: true, value: undefined };
|
| 58 |
+
};
|
| 59 |
+
}
|
| 60 |
+
});
|
| 61 |
+
drop(obj, {
|
| 62 |
+
valueOf: function valueOf() {
|
| 63 |
+
effects.push('ToNumber limit');
|
| 64 |
+
return 0;
|
| 65 |
+
}
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
st.deepEqual(effects, [
|
| 69 |
+
'ToNumber limit',
|
| 70 |
+
'get next'
|
| 71 |
+
]);
|
| 72 |
+
st.end();
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
var arr = [1, 2, 3];
|
| 76 |
+
|
| 77 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 78 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 79 |
+
|
| 80 |
+
st['throws'](
|
| 81 |
+
function () { drop(iterator(), -3); },
|
| 82 |
+
RangeError,
|
| 83 |
+
'-3 is not >= 0'
|
| 84 |
+
);
|
| 85 |
+
|
| 86 |
+
st['throws'](
|
| 87 |
+
function () { return new drop(iterator()); }, // eslint-disable-line new-cap
|
| 88 |
+
TypeError,
|
| 89 |
+
'`' + name + '` iterator is not a constructor'
|
| 90 |
+
);
|
| 91 |
+
st['throws'](
|
| 92 |
+
function () { return new drop(iterator(), 0); }, // eslint-disable-line new-cap
|
| 93 |
+
TypeError,
|
| 94 |
+
'`' + name + '` iterator is not a constructor'
|
| 95 |
+
);
|
| 96 |
+
|
| 97 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 98 |
+
testIterator(drop(iterator(), 0), [1, 2, 3], st, 'drop 0');
|
| 99 |
+
testIterator(drop(iterator(), 1), [2, 3], st, 'drop 1');
|
| 100 |
+
testIterator(drop(iterator(), 2), [3], st, 'drop 2');
|
| 101 |
+
testIterator(drop(iterator(), 3), [], st, 'drop 3');
|
| 102 |
+
testIterator(drop(iterator(), Infinity), [], st, 'drop ∞');
|
| 103 |
+
|
| 104 |
+
st.test('262: limit-tonumber', function (s2t) {
|
| 105 |
+
// ToNumber coercion
|
| 106 |
+
testIterator(drop(iterator(), '1'), [2, 3], s2t, 'string "1" coerced to 1');
|
| 107 |
+
testIterator(drop(iterator(), 1.9), [2, 3], s2t, '1.9 truncated to 1');
|
| 108 |
+
testIterator(drop(iterator(), { valueOf: function () { return 1; } }), [2, 3], s2t, 'object with valueOf');
|
| 109 |
+
testIterator(drop(iterator(), true), [2, 3], s2t, 'true coerced to 1');
|
| 110 |
+
testIterator(drop(iterator(), null), [1, 2, 3], s2t, 'null coerced to 0');
|
| 111 |
+
|
| 112 |
+
s2t.end();
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
st.test('262: limit-tonumber-throws', function (s2t) {
|
| 116 |
+
s2t['throws'](
|
| 117 |
+
function () { drop(iterator(), { valueOf: function () { throw new EvalError('valueOf threw'); } }); },
|
| 118 |
+
EvalError,
|
| 119 |
+
'throws when valueOf throws'
|
| 120 |
+
);
|
| 121 |
+
|
| 122 |
+
s2t['throws'](
|
| 123 |
+
function () { drop(iterator(), Symbol('test')); },
|
| 124 |
+
TypeError,
|
| 125 |
+
'throws when limit is a Symbol'
|
| 126 |
+
);
|
| 127 |
+
|
| 128 |
+
s2t.end();
|
| 129 |
+
});
|
| 130 |
+
|
| 131 |
+
st.test('262: limit-rangeerror', function (s2t) {
|
| 132 |
+
s2t['throws'](function () { drop(iterator(), -1); }, RangeError, '-1 throws RangeError');
|
| 133 |
+
s2t['throws'](function () { drop(iterator(), -Infinity); }, RangeError, '-Infinity throws RangeError');
|
| 134 |
+
s2t['throws'](function () { drop(iterator(), NaN); }, RangeError, 'NaN throws RangeError');
|
| 135 |
+
|
| 136 |
+
s2t.end();
|
| 137 |
+
});
|
| 138 |
+
|
| 139 |
+
st.test('262: result is iterator', function (s2t) {
|
| 140 |
+
var iter = drop(iterator(), 1);
|
| 141 |
+
s2t.equal(typeof iter.next, 'function', 'has next method');
|
| 142 |
+
s2t.equal(typeof iter[Symbol.iterator], 'function', 'has Symbol.iterator method');
|
| 143 |
+
s2t.equal(iter[Symbol.iterator](), iter, 'Symbol.iterator returns itself');
|
| 144 |
+
|
| 145 |
+
s2t.end();
|
| 146 |
+
});
|
| 147 |
+
|
| 148 |
+
st.test('262: get next method only once', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 149 |
+
var nextGets = 0;
|
| 150 |
+
var testIter = {};
|
| 151 |
+
Object.defineProperty(testIter, 'next', {
|
| 152 |
+
get: function () {
|
| 153 |
+
nextGets += 1;
|
| 154 |
+
return function () {
|
| 155 |
+
return { done: true, value: undefined };
|
| 156 |
+
};
|
| 157 |
+
}
|
| 158 |
+
});
|
| 159 |
+
|
| 160 |
+
var iter = drop(testIter, 1);
|
| 161 |
+
s2t.equal(nextGets, 1, 'next retrieved once on creation');
|
| 162 |
+
iter.next();
|
| 163 |
+
s2t.equal(nextGets, 1, 'next not retrieved again');
|
| 164 |
+
|
| 165 |
+
s2t.end();
|
| 166 |
+
});
|
| 167 |
+
|
| 168 |
+
st.test('262: next method returns non-object throws', function (s2t) {
|
| 169 |
+
var badIterator = {
|
| 170 |
+
next: function () {
|
| 171 |
+
return null;
|
| 172 |
+
}
|
| 173 |
+
};
|
| 174 |
+
|
| 175 |
+
var iter = drop(badIterator, 1);
|
| 176 |
+
s2t['throws'](function () { iter.next(); }, TypeError, 'throws when next returns null');
|
| 177 |
+
|
| 178 |
+
s2t.end();
|
| 179 |
+
});
|
| 180 |
+
|
| 181 |
+
st.test('262: next method returns throwing done', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 182 |
+
var throwingIterator = {
|
| 183 |
+
next: function () {
|
| 184 |
+
var result = { value: 1 };
|
| 185 |
+
Object.defineProperty(result, 'done', {
|
| 186 |
+
get: function () {
|
| 187 |
+
throw new EvalError('done getter threw');
|
| 188 |
+
}
|
| 189 |
+
});
|
| 190 |
+
return result;
|
| 191 |
+
}
|
| 192 |
+
};
|
| 193 |
+
|
| 194 |
+
var iter = drop(throwingIterator, 1);
|
| 195 |
+
s2t['throws'](function () { iter.next(); }, EvalError, 'throws when done getter throws');
|
| 196 |
+
|
| 197 |
+
s2t.end();
|
| 198 |
+
});
|
| 199 |
+
|
| 200 |
+
st.test('262: next method throws', function (s2t) {
|
| 201 |
+
var throwingIterator = {
|
| 202 |
+
next: function () {
|
| 203 |
+
throw new EvalError('next threw');
|
| 204 |
+
}
|
| 205 |
+
};
|
| 206 |
+
|
| 207 |
+
var iter = drop(throwingIterator, 1);
|
| 208 |
+
s2t['throws'](function () { iter.next(); }, EvalError, 'throws error from next');
|
| 209 |
+
|
| 210 |
+
s2t.end();
|
| 211 |
+
});
|
| 212 |
+
|
| 213 |
+
st.test('262: throws TypeError when generator is running', function (s2t) {
|
| 214 |
+
var reentrantIterator;
|
| 215 |
+
var testIter = {
|
| 216 |
+
next: function () {
|
| 217 |
+
reentrantIterator.next();
|
| 218 |
+
return { done: false, value: 1 };
|
| 219 |
+
}
|
| 220 |
+
};
|
| 221 |
+
|
| 222 |
+
reentrantIterator = drop(testIter, 0);
|
| 223 |
+
s2t['throws'](function () { reentrantIterator.next(); }, TypeError, 'throws on reentrant next()');
|
| 224 |
+
|
| 225 |
+
s2t.end();
|
| 226 |
+
});
|
| 227 |
+
|
| 228 |
+
st.test('262: limit-equals-total', function (s2t) {
|
| 229 |
+
testIterator(drop(iterator(), 3), [], s2t, 'drop exactly 3 from 3-item iterator');
|
| 230 |
+
|
| 231 |
+
s2t.end();
|
| 232 |
+
});
|
| 233 |
+
|
| 234 |
+
st.test('262: limit-greater-than-total', function (s2t) {
|
| 235 |
+
testIterator(drop(iterator(), 5), [], s2t, 'drop 5 from 3-item iterator');
|
| 236 |
+
testIterator(drop(iterator(), 100), [], s2t, 'drop 100 from 3-item iterator');
|
| 237 |
+
|
| 238 |
+
s2t.end();
|
| 239 |
+
});
|
| 240 |
+
|
| 241 |
+
st.test('262: limit-less-than-total', function (s2t) {
|
| 242 |
+
testIterator(drop(iterator(), 1), [2, 3], s2t, 'drop 1 from 3-item iterator');
|
| 243 |
+
testIterator(drop(iterator(), 2), [3], s2t, 'drop 2 from 3-item iterator');
|
| 244 |
+
|
| 245 |
+
s2t.end();
|
| 246 |
+
});
|
| 247 |
+
|
| 248 |
+
st.test('262: exhaustion does not call return', function (s2t) {
|
| 249 |
+
var returnCalls = 0;
|
| 250 |
+
|
| 251 |
+
var testIter = {
|
| 252 |
+
next: function () {
|
| 253 |
+
return { done: true, value: undefined };
|
| 254 |
+
},
|
| 255 |
+
'return': function () {
|
| 256 |
+
returnCalls += 1;
|
| 257 |
+
return { done: true, value: undefined };
|
| 258 |
+
}
|
| 259 |
+
};
|
| 260 |
+
|
| 261 |
+
var iter = drop(testIter, 1);
|
| 262 |
+
iter.next();
|
| 263 |
+
s2t.equal(returnCalls, 0, 'return not called on exhaustion');
|
| 264 |
+
|
| 265 |
+
s2t.end();
|
| 266 |
+
});
|
| 267 |
+
|
| 268 |
+
st.end();
|
| 269 |
+
});
|
| 270 |
+
|
| 271 |
+
t.test('262: test/built-ins/Iterator/prototype/drop/get-return-method-throws', { skip: !hasPropertyDescriptors }, function (st) {
|
| 272 |
+
var badIterator = {
|
| 273 |
+
next: function next() {
|
| 274 |
+
return {
|
| 275 |
+
done: false,
|
| 276 |
+
value: 1
|
| 277 |
+
};
|
| 278 |
+
}
|
| 279 |
+
};
|
| 280 |
+
|
| 281 |
+
Object.defineProperty(badIterator, 'return', {
|
| 282 |
+
configurable: true,
|
| 283 |
+
enumerable: true,
|
| 284 |
+
get: function () { throw new SyntaxError(); }
|
| 285 |
+
});
|
| 286 |
+
|
| 287 |
+
var iter = drop(badIterator, 1);
|
| 288 |
+
iter.next();
|
| 289 |
+
|
| 290 |
+
st['throws'](
|
| 291 |
+
function () { iter['return'](); },
|
| 292 |
+
SyntaxError,
|
| 293 |
+
'gets the `return` method, whose getter throws'
|
| 294 |
+
);
|
| 295 |
+
|
| 296 |
+
st.end();
|
| 297 |
+
});
|
| 298 |
+
|
| 299 |
+
t.test('262: test/built-ins/Iterator/prototype/drop/return-is-forwarded', function (st) {
|
| 300 |
+
var returnCount = 0;
|
| 301 |
+
|
| 302 |
+
var makeBadIterator = function makeBadIterator() {
|
| 303 |
+
return {
|
| 304 |
+
next: function next() {
|
| 305 |
+
return {
|
| 306 |
+
done: false,
|
| 307 |
+
value: 1
|
| 308 |
+
};
|
| 309 |
+
},
|
| 310 |
+
'return': function () {
|
| 311 |
+
returnCount += 1;
|
| 312 |
+
return {};
|
| 313 |
+
}
|
| 314 |
+
};
|
| 315 |
+
};
|
| 316 |
+
|
| 317 |
+
var iter1 = drop(makeBadIterator(), 0);
|
| 318 |
+
st.equal(returnCount, 0, 'iter1, before return()');
|
| 319 |
+
iter1['return']();
|
| 320 |
+
st.equal(returnCount, 1, 'iter1, after return()'); // TODO
|
| 321 |
+
|
| 322 |
+
var iter2 = drop(makeBadIterator(), 1);
|
| 323 |
+
st.equal(returnCount, 1, 'iter2, before return()'); // TODO
|
| 324 |
+
iter2['return']();
|
| 325 |
+
st.equal(returnCount, 2, 'iter2, after return()'); // TODO
|
| 326 |
+
|
| 327 |
+
// 5 drops (i wish i had pipeline)
|
| 328 |
+
var iter3 = drop(
|
| 329 |
+
drop(
|
| 330 |
+
drop(
|
| 331 |
+
drop(
|
| 332 |
+
drop(
|
| 333 |
+
makeBadIterator(),
|
| 334 |
+
1
|
| 335 |
+
),
|
| 336 |
+
1
|
| 337 |
+
),
|
| 338 |
+
1
|
| 339 |
+
),
|
| 340 |
+
1
|
| 341 |
+
),
|
| 342 |
+
1
|
| 343 |
+
);
|
| 344 |
+
st.equal(returnCount, 2, 'iter3, before return()'); // TODO
|
| 345 |
+
iter3['return']();
|
| 346 |
+
st.equal(returnCount, 3, 'iter3, after return()'); // TODO
|
| 347 |
+
|
| 348 |
+
st.end();
|
| 349 |
+
});
|
| 350 |
+
|
| 351 |
+
t.test('262: test/built-ins/Iterator/prototype/drop/return-is-not-forwarded-after-exhaustion', { skip: !hasPropertyDescriptors }, function (st) {
|
| 352 |
+
var makeBadIterator = function makeBadIterator() {
|
| 353 |
+
return {
|
| 354 |
+
next: function next() {
|
| 355 |
+
return {
|
| 356 |
+
done: true,
|
| 357 |
+
value: undefined
|
| 358 |
+
};
|
| 359 |
+
},
|
| 360 |
+
'return': function () {
|
| 361 |
+
throw new SyntaxError();
|
| 362 |
+
}
|
| 363 |
+
};
|
| 364 |
+
};
|
| 365 |
+
|
| 366 |
+
var iter1 = drop(makeBadIterator(), 0); // TODO
|
| 367 |
+
st['throws'](
|
| 368 |
+
function () { iter1['return'](); },
|
| 369 |
+
SyntaxError,
|
| 370 |
+
'iter1, return() throws'
|
| 371 |
+
);
|
| 372 |
+
iter1.next();
|
| 373 |
+
iter1['return']();
|
| 374 |
+
|
| 375 |
+
var iter2 = drop(makeBadIterator(), 1);
|
| 376 |
+
st['throws'](
|
| 377 |
+
function () { iter2['return'](); },
|
| 378 |
+
SyntaxError,
|
| 379 |
+
'iter2, return() throws'
|
| 380 |
+
);
|
| 381 |
+
iter2.next();
|
| 382 |
+
iter2['return']();
|
| 383 |
+
|
| 384 |
+
// 5 drops (i wish i had pipeline)
|
| 385 |
+
var iter3 = drop(
|
| 386 |
+
drop(
|
| 387 |
+
drop(
|
| 388 |
+
drop(
|
| 389 |
+
drop(
|
| 390 |
+
makeBadIterator(),
|
| 391 |
+
1
|
| 392 |
+
),
|
| 393 |
+
1
|
| 394 |
+
),
|
| 395 |
+
1
|
| 396 |
+
),
|
| 397 |
+
1
|
| 398 |
+
),
|
| 399 |
+
1
|
| 400 |
+
);
|
| 401 |
+
st['throws'](
|
| 402 |
+
function () { iter3['return'](); },
|
| 403 |
+
SyntaxError,
|
| 404 |
+
'iter3, return() throws'
|
| 405 |
+
);
|
| 406 |
+
iter3.next();
|
| 407 |
+
iter3['return']();
|
| 408 |
+
|
| 409 |
+
var iter4 = drop(makeBadIterator(), 10);
|
| 410 |
+
st['throws'](
|
| 411 |
+
function () { iter4['return'](); },
|
| 412 |
+
SyntaxError,
|
| 413 |
+
'iter4, return() throws'
|
| 414 |
+
);
|
| 415 |
+
iter4.next();
|
| 416 |
+
iter4['return']();
|
| 417 |
+
|
| 418 |
+
st.end();
|
| 419 |
+
});
|
| 420 |
+
},
|
| 421 |
+
index: function () {
|
| 422 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 423 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 424 |
+
|
| 425 |
+
t.end();
|
| 426 |
+
});
|
| 427 |
+
},
|
| 428 |
+
implementation: function () {
|
| 429 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 430 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 431 |
+
|
| 432 |
+
t.end();
|
| 433 |
+
});
|
| 434 |
+
},
|
| 435 |
+
shimmed: function () {
|
| 436 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 437 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 438 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 439 |
+
st.end();
|
| 440 |
+
});
|
| 441 |
+
|
| 442 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 443 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 444 |
+
et.end();
|
| 445 |
+
});
|
| 446 |
+
|
| 447 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 448 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 449 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 450 |
+
st.end();
|
| 451 |
+
});
|
| 452 |
+
|
| 453 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 454 |
+
|
| 455 |
+
t.end();
|
| 456 |
+
});
|
| 457 |
+
}
|
| 458 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.every.js
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 13 |
+
var iterate = require('iterate-iterator');
|
| 14 |
+
|
| 15 |
+
var index = require('../Iterator.prototype.every');
|
| 16 |
+
var impl = require('../Iterator.prototype.every/implementation');
|
| 17 |
+
|
| 18 |
+
var fnName = 'every';
|
| 19 |
+
|
| 20 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 21 |
+
|
| 22 |
+
var testIterator = require('./helpers/testIterator');
|
| 23 |
+
|
| 24 |
+
module.exports = {
|
| 25 |
+
tests: function (every, name, t) {
|
| 26 |
+
t['throws'](
|
| 27 |
+
function () { return new every(); }, // eslint-disable-line new-cap
|
| 28 |
+
TypeError,
|
| 29 |
+
'`' + name + '` is not a constructor'
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 33 |
+
t['throws'](
|
| 34 |
+
function () { iterate(every(nonIterator, function () {})); },
|
| 35 |
+
TypeError,
|
| 36 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 37 |
+
);
|
| 38 |
+
|
| 39 |
+
var badNext = { next: nonIterator };
|
| 40 |
+
t['throws'](
|
| 41 |
+
function () { iterate(every(badNext, function () {})); },
|
| 42 |
+
TypeError,
|
| 43 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 44 |
+
);
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 48 |
+
t['throws'](
|
| 49 |
+
function () { every({ next: function () {} }, nonFunction); },
|
| 50 |
+
TypeError,
|
| 51 |
+
debug(nonFunction) + ' is not a function'
|
| 52 |
+
);
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
t.test('observable lookups', { skip: !hasPropertyDescriptors }, function (st) {
|
| 56 |
+
var effects = [];
|
| 57 |
+
|
| 58 |
+
var obj = {};
|
| 59 |
+
Object.defineProperty(obj, 'next', {
|
| 60 |
+
configurable: true,
|
| 61 |
+
enumerable: true,
|
| 62 |
+
get: function next() {
|
| 63 |
+
effects.push('get next');
|
| 64 |
+
return function () {
|
| 65 |
+
return { done: true, value: undefined };
|
| 66 |
+
};
|
| 67 |
+
}
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
st['throws'](
|
| 71 |
+
function () { every(obj, null); },
|
| 72 |
+
TypeError
|
| 73 |
+
);
|
| 74 |
+
|
| 75 |
+
st.deepEqual(effects, []);
|
| 76 |
+
|
| 77 |
+
st.end();
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 81 |
+
var arr = [1, 2, 3];
|
| 82 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 83 |
+
|
| 84 |
+
st['throws'](
|
| 85 |
+
function () { return new every(iterator()); }, // eslint-disable-line new-cap
|
| 86 |
+
TypeError,
|
| 87 |
+
'`' + name + '` iterator is not a constructor'
|
| 88 |
+
);
|
| 89 |
+
st['throws'](
|
| 90 |
+
function () { return new every(iterator(), function () {}); }, // eslint-disable-line new-cap
|
| 91 |
+
TypeError,
|
| 92 |
+
'`' + name + '` iterator is not a constructor'
|
| 93 |
+
);
|
| 94 |
+
|
| 95 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 96 |
+
st.equal(every(iterator(), function () { return false; }), false, 'every for always-false');
|
| 97 |
+
st.equal(every(iterator(), function () { return true; }), true, 'every for always-true');
|
| 98 |
+
st.equal(every(iterator(), function (x, i) { return x === 2 && i === 1; }), false, 'every returns false for matching value/index');
|
| 99 |
+
|
| 100 |
+
st.test('test262: test/built-ins/Iterator/prototype/every/predicate-args', function (s2t) {
|
| 101 |
+
var assertionCount = 0;
|
| 102 |
+
var result = every(
|
| 103 |
+
['a', 'b', 'c'][Symbol.iterator](),
|
| 104 |
+
function (value, count) {
|
| 105 |
+
if (value === 'a') {
|
| 106 |
+
s2t.equal(count, 0);
|
| 107 |
+
} else if (value === 'b') {
|
| 108 |
+
s2t.equal(count, 1);
|
| 109 |
+
} else if (value === 'c') {
|
| 110 |
+
s2t.equal(count, 2);
|
| 111 |
+
} else {
|
| 112 |
+
s2t.fail('unexpected value');
|
| 113 |
+
}
|
| 114 |
+
assertionCount += 1;
|
| 115 |
+
return true;
|
| 116 |
+
}
|
| 117 |
+
);
|
| 118 |
+
s2t.equal(result, true, 'every returns true when all pass');
|
| 119 |
+
s2t.equal(assertionCount, 3, 'predicate called three times');
|
| 120 |
+
|
| 121 |
+
s2t.end();
|
| 122 |
+
});
|
| 123 |
+
|
| 124 |
+
st.test('test262: test/built-ins/Iterator/prototype/every/predicate-this', function (s2t) {
|
| 125 |
+
var expectedThis = (function () { return this; }()); // eslint-disable-line no-invalid-this
|
| 126 |
+
var assertionCount = 0;
|
| 127 |
+
var result = every(
|
| 128 |
+
[0][Symbol.iterator](),
|
| 129 |
+
function () {
|
| 130 |
+
s2t.equal(this, expectedThis, 'predicate this is undefined'); // eslint-disable-line no-invalid-this
|
| 131 |
+
assertionCount += 1;
|
| 132 |
+
return true;
|
| 133 |
+
}
|
| 134 |
+
);
|
| 135 |
+
s2t.equal(result, true);
|
| 136 |
+
s2t.equal(assertionCount, 1);
|
| 137 |
+
|
| 138 |
+
s2t.end();
|
| 139 |
+
});
|
| 140 |
+
|
| 141 |
+
st.test('test262: test/built-ins/Iterator/prototype/every/predicate-returns-truthy', function (s2t) {
|
| 142 |
+
var result = every(
|
| 143 |
+
[0, 1, 2, 3, 4][Symbol.iterator](),
|
| 144 |
+
function () { return true; }
|
| 145 |
+
);
|
| 146 |
+
s2t.equal(result, true, 'every returns true when predicate always returns truthy');
|
| 147 |
+
|
| 148 |
+
s2t.end();
|
| 149 |
+
});
|
| 150 |
+
|
| 151 |
+
st.test('test262: test/built-ins/Iterator/prototype/every/predicate-returns-falsey', function (s2t) {
|
| 152 |
+
var result = every(
|
| 153 |
+
[0, 1, 2, 3, 4][Symbol.iterator](),
|
| 154 |
+
function () { return false; }
|
| 155 |
+
);
|
| 156 |
+
s2t.equal(result, false, 'every returns false when predicate returns falsey');
|
| 157 |
+
|
| 158 |
+
s2t.end();
|
| 159 |
+
});
|
| 160 |
+
|
| 161 |
+
st.test('test262: test/built-ins/Iterator/prototype/every/predicate-returns-truthy-then-falsey', function (s2t) {
|
| 162 |
+
var callCount = 0;
|
| 163 |
+
var returnCalled = false;
|
| 164 |
+
var values = [0, 1, 2, 3, 4];
|
| 165 |
+
var idx = 0;
|
| 166 |
+
var iter = {
|
| 167 |
+
next: function () {
|
| 168 |
+
if (idx < values.length) {
|
| 169 |
+
var val = values[idx];
|
| 170 |
+
idx += 1;
|
| 171 |
+
return { done: false, value: val };
|
| 172 |
+
}
|
| 173 |
+
return { done: true, value: undefined };
|
| 174 |
+
},
|
| 175 |
+
'return': function () {
|
| 176 |
+
returnCalled = true;
|
| 177 |
+
return { done: true, value: undefined };
|
| 178 |
+
}
|
| 179 |
+
};
|
| 180 |
+
var result = every(
|
| 181 |
+
iter,
|
| 182 |
+
function (value) {
|
| 183 |
+
callCount += 1;
|
| 184 |
+
return value < 3;
|
| 185 |
+
}
|
| 186 |
+
);
|
| 187 |
+
s2t.equal(result, false, 'every returns false when predicate returns falsey');
|
| 188 |
+
s2t.equal(callCount, 4, 'predicate called until falsey returned');
|
| 189 |
+
s2t.equal(returnCalled, true, 'iterator is closed');
|
| 190 |
+
|
| 191 |
+
s2t.end();
|
| 192 |
+
});
|
| 193 |
+
|
| 194 |
+
st.test('test262: test/built-ins/Iterator/prototype/every/predicate-returns-non-boolean', function (s2t) {
|
| 195 |
+
// truthy non-boolean values
|
| 196 |
+
s2t.equal(every([1][Symbol.iterator](), function () { return 1; }), true, 'truthy number');
|
| 197 |
+
s2t.equal(every([1][Symbol.iterator](), function () { return 'yes'; }), true, 'truthy string');
|
| 198 |
+
s2t.equal(every([1][Symbol.iterator](), function () { return {}; }), true, 'truthy object');
|
| 199 |
+
|
| 200 |
+
// falsy non-boolean values
|
| 201 |
+
s2t.equal(every([1][Symbol.iterator](), function () { return 0; }), false, 'falsy number');
|
| 202 |
+
s2t.equal(every([1][Symbol.iterator](), function () { return ''; }), false, 'falsy string');
|
| 203 |
+
s2t.equal(every([1][Symbol.iterator](), function () { return null; }), false, 'null');
|
| 204 |
+
|
| 205 |
+
s2t.end();
|
| 206 |
+
});
|
| 207 |
+
|
| 208 |
+
st.test('test262: test/built-ins/Iterator/prototype/every/predicate-throws', function (s2t) {
|
| 209 |
+
var returnCount = 0;
|
| 210 |
+
var testIter = {
|
| 211 |
+
next: function () {
|
| 212 |
+
return { done: false, value: 1 };
|
| 213 |
+
},
|
| 214 |
+
'return': function () {
|
| 215 |
+
returnCount += 1;
|
| 216 |
+
return { done: true };
|
| 217 |
+
}
|
| 218 |
+
};
|
| 219 |
+
|
| 220 |
+
var callbackCount = 0;
|
| 221 |
+
s2t['throws'](
|
| 222 |
+
function () {
|
| 223 |
+
every(testIter, function () {
|
| 224 |
+
callbackCount += 1;
|
| 225 |
+
throw new SyntaxError('predicate threw');
|
| 226 |
+
});
|
| 227 |
+
},
|
| 228 |
+
SyntaxError
|
| 229 |
+
);
|
| 230 |
+
s2t.equal(callbackCount, 1, 'predicate called once');
|
| 231 |
+
s2t.equal(returnCount, 1, 'iterator closed when predicate throws');
|
| 232 |
+
|
| 233 |
+
s2t.end();
|
| 234 |
+
});
|
| 235 |
+
|
| 236 |
+
st.test('test262: test/built-ins/Iterator/prototype/every/iterator-already-exhausted', function (s2t) {
|
| 237 |
+
var iter = [][Symbol.iterator]();
|
| 238 |
+
var callbackCount = 0;
|
| 239 |
+
var result = every(iter, function () {
|
| 240 |
+
callbackCount += 1;
|
| 241 |
+
return true;
|
| 242 |
+
});
|
| 243 |
+
s2t.equal(result, true, 'every returns true for empty iterator');
|
| 244 |
+
s2t.equal(callbackCount, 0, 'predicate not called');
|
| 245 |
+
|
| 246 |
+
s2t.end();
|
| 247 |
+
});
|
| 248 |
+
|
| 249 |
+
st.end();
|
| 250 |
+
});
|
| 251 |
+
},
|
| 252 |
+
index: function () {
|
| 253 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 254 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 255 |
+
|
| 256 |
+
t.end();
|
| 257 |
+
});
|
| 258 |
+
},
|
| 259 |
+
implementation: function () {
|
| 260 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 261 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 262 |
+
|
| 263 |
+
t.end();
|
| 264 |
+
});
|
| 265 |
+
},
|
| 266 |
+
shimmed: function () {
|
| 267 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 268 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 269 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 270 |
+
st.end();
|
| 271 |
+
});
|
| 272 |
+
|
| 273 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 274 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 275 |
+
et.end();
|
| 276 |
+
});
|
| 277 |
+
|
| 278 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 279 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 280 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 281 |
+
st.end();
|
| 282 |
+
});
|
| 283 |
+
|
| 284 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 285 |
+
|
| 286 |
+
t.end();
|
| 287 |
+
});
|
| 288 |
+
}
|
| 289 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.filter.js
ADDED
|
@@ -0,0 +1,559 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 13 |
+
var iterate = require('iterate-iterator');
|
| 14 |
+
|
| 15 |
+
var index = require('../Iterator.prototype.filter');
|
| 16 |
+
var impl = require('../Iterator.prototype.filter/implementation');
|
| 17 |
+
|
| 18 |
+
var fnName = 'filter';
|
| 19 |
+
|
| 20 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 21 |
+
|
| 22 |
+
var testIterator = require('./helpers/testIterator');
|
| 23 |
+
|
| 24 |
+
module.exports = {
|
| 25 |
+
tests: function (filter, name, t) {
|
| 26 |
+
t['throws'](
|
| 27 |
+
function () { return new filter(); }, // eslint-disable-line new-cap
|
| 28 |
+
TypeError,
|
| 29 |
+
'`' + name + '` is not a constructor'
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 33 |
+
t['throws'](
|
| 34 |
+
function () { iterate(filter(nonIterator, function () {})); },
|
| 35 |
+
TypeError,
|
| 36 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 37 |
+
);
|
| 38 |
+
|
| 39 |
+
var badNext = { next: nonIterator };
|
| 40 |
+
t['throws'](
|
| 41 |
+
function () { iterate(filter(badNext, function () {})); },
|
| 42 |
+
TypeError,
|
| 43 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 44 |
+
);
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 48 |
+
t['throws'](
|
| 49 |
+
function () { filter({ next: function () {} }, nonFunction); },
|
| 50 |
+
TypeError,
|
| 51 |
+
debug(nonFunction) + ' is not a function'
|
| 52 |
+
);
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
t.test('observable lookups', { skip: !hasPropertyDescriptors }, function (st) {
|
| 56 |
+
var effects = [];
|
| 57 |
+
|
| 58 |
+
var obj = {};
|
| 59 |
+
Object.defineProperty(obj, 'next', {
|
| 60 |
+
configurable: true,
|
| 61 |
+
enumerable: true,
|
| 62 |
+
get: function next() {
|
| 63 |
+
effects.push('get next');
|
| 64 |
+
return function () {
|
| 65 |
+
return { done: true, value: undefined };
|
| 66 |
+
};
|
| 67 |
+
}
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
st['throws'](
|
| 71 |
+
function () { filter(obj, null); },
|
| 72 |
+
TypeError
|
| 73 |
+
);
|
| 74 |
+
|
| 75 |
+
st.deepEqual(effects, []);
|
| 76 |
+
|
| 77 |
+
st.end();
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 81 |
+
var arr = [1, 2, 3];
|
| 82 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 83 |
+
|
| 84 |
+
st['throws'](
|
| 85 |
+
function () { return new filter(iterator()); }, // eslint-disable-line new-cap
|
| 86 |
+
TypeError,
|
| 87 |
+
'`' + name + '` iterator is not a constructor'
|
| 88 |
+
);
|
| 89 |
+
st['throws'](
|
| 90 |
+
function () { return new filter(iterator(), function () {}); }, // eslint-disable-line new-cap
|
| 91 |
+
TypeError,
|
| 92 |
+
'`' + name + '` iterator is not a constructor'
|
| 93 |
+
);
|
| 94 |
+
|
| 95 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 96 |
+
testIterator(filter(iterator(), function () { return false; }), [], st, 'filter for always-false');
|
| 97 |
+
testIterator(filter(iterator(), function () { return true; }), [1, 2, 3], st, 'filter for always-true');
|
| 98 |
+
testIterator(filter(iterator(), function (x, i) { return x === 2 && i === 1; }), [2], st, 'filter returns value for matching value/index');
|
| 99 |
+
|
| 100 |
+
st.end();
|
| 101 |
+
});
|
| 102 |
+
|
| 103 |
+
t.test('262: test/built-ins/Iterator/prototype/filter/predicate-args', function (st) {
|
| 104 |
+
var g = function g() {
|
| 105 |
+
var arr = ['a', 'b', 'c'];
|
| 106 |
+
var i = 0;
|
| 107 |
+
return {
|
| 108 |
+
next: function () {
|
| 109 |
+
try {
|
| 110 |
+
return {
|
| 111 |
+
value: arr[i],
|
| 112 |
+
done: i >= arr.length
|
| 113 |
+
};
|
| 114 |
+
} finally {
|
| 115 |
+
i += 1;
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
};
|
| 119 |
+
};
|
| 120 |
+
var assertionCount = 0;
|
| 121 |
+
var iter = filter(
|
| 122 |
+
g(),
|
| 123 |
+
function (value, count) {
|
| 124 |
+
if (value === 'a') {
|
| 125 |
+
st.equal(count, 0, 'first iteration');
|
| 126 |
+
} else if (value === 'b') {
|
| 127 |
+
st.equal(count, 1, 'second iteration');
|
| 128 |
+
} else if (value === 'c') {
|
| 129 |
+
st.equal(count, 2, 'third iteration');
|
| 130 |
+
} else {
|
| 131 |
+
st.fail('unexpected iteration');
|
| 132 |
+
}
|
| 133 |
+
assertionCount += 1;
|
| 134 |
+
return true;
|
| 135 |
+
}
|
| 136 |
+
);
|
| 137 |
+
|
| 138 |
+
st.equal(assertionCount, 0, 'prior to iteration');
|
| 139 |
+
|
| 140 |
+
testIterator(iter, ['a', 'b', 'c'], st, 'iteration');
|
| 141 |
+
|
| 142 |
+
st.equal(assertionCount, 3);
|
| 143 |
+
|
| 144 |
+
st.end();
|
| 145 |
+
});
|
| 146 |
+
|
| 147 |
+
t.test('262: test/built-ins/Iterator/prototype/filter/predicate-throws', function (st) {
|
| 148 |
+
var returnCalls = 0;
|
| 149 |
+
|
| 150 |
+
var iter = {
|
| 151 |
+
next: function () {
|
| 152 |
+
return {
|
| 153 |
+
done: false,
|
| 154 |
+
value: 1
|
| 155 |
+
};
|
| 156 |
+
},
|
| 157 |
+
'return': function () {
|
| 158 |
+
returnCalls += 1;
|
| 159 |
+
return {};
|
| 160 |
+
}
|
| 161 |
+
};
|
| 162 |
+
|
| 163 |
+
var callbackCalls = 0;
|
| 164 |
+
var iterator = filter(iter, function () {
|
| 165 |
+
callbackCalls += 1;
|
| 166 |
+
throw new SyntaxError();
|
| 167 |
+
});
|
| 168 |
+
|
| 169 |
+
st['throws'](function () { iterator.next(); }, SyntaxError, 'next() throws');
|
| 170 |
+
|
| 171 |
+
st.equal(callbackCalls, 1);
|
| 172 |
+
st.equal(returnCalls, 1);
|
| 173 |
+
|
| 174 |
+
st.end();
|
| 175 |
+
});
|
| 176 |
+
|
| 177 |
+
t.test('262: test/built-ins/Iterator/prototype/filter/predicate-throws-then-closing-iterator-also-throws', function (st) {
|
| 178 |
+
var iter = {
|
| 179 |
+
next: function next() {
|
| 180 |
+
return {
|
| 181 |
+
done: false,
|
| 182 |
+
value: 1
|
| 183 |
+
};
|
| 184 |
+
},
|
| 185 |
+
'return': function () {
|
| 186 |
+
throw new EvalError();
|
| 187 |
+
}
|
| 188 |
+
};
|
| 189 |
+
|
| 190 |
+
var iterator = filter(iter, function () {
|
| 191 |
+
throw new SyntaxError();
|
| 192 |
+
});
|
| 193 |
+
|
| 194 |
+
st['throws'](
|
| 195 |
+
function () { iterator.next(); },
|
| 196 |
+
SyntaxError,
|
| 197 |
+
'when the predicate and return() both throw, the predicate’s exception wins'
|
| 198 |
+
);
|
| 199 |
+
|
| 200 |
+
st.end();
|
| 201 |
+
});
|
| 202 |
+
|
| 203 |
+
t.test('262: test/built-ins/Iterator/prototype/filter/get-return-method-throws', { skip: !hasPropertyDescriptors }, function (st) {
|
| 204 |
+
var badIterator = {
|
| 205 |
+
next: function next() {
|
| 206 |
+
return {
|
| 207 |
+
done: false,
|
| 208 |
+
value: 1
|
| 209 |
+
};
|
| 210 |
+
}
|
| 211 |
+
};
|
| 212 |
+
|
| 213 |
+
Object.defineProperty(badIterator, 'return', { get: function () { throw new SyntaxError(); } });
|
| 214 |
+
|
| 215 |
+
var iter = filter(badIterator, function () { return true; });
|
| 216 |
+
iter.next();
|
| 217 |
+
|
| 218 |
+
st['throws'](
|
| 219 |
+
function () { iter['return'](); },
|
| 220 |
+
SyntaxError,
|
| 221 |
+
'gets the `return` method, whose getter throws'
|
| 222 |
+
);
|
| 223 |
+
|
| 224 |
+
st.end();
|
| 225 |
+
});
|
| 226 |
+
|
| 227 |
+
t.test('262: test/built-ins/Iterator/prototype/drop/return-is-forwarded', function (st) {
|
| 228 |
+
var returnCount = 0;
|
| 229 |
+
|
| 230 |
+
var badIterator = {
|
| 231 |
+
next: function next() {
|
| 232 |
+
return {
|
| 233 |
+
done: false,
|
| 234 |
+
value: 1
|
| 235 |
+
};
|
| 236 |
+
},
|
| 237 |
+
'return': function () {
|
| 238 |
+
returnCount += 1;
|
| 239 |
+
return {};
|
| 240 |
+
}
|
| 241 |
+
};
|
| 242 |
+
|
| 243 |
+
var iter1 = filter(badIterator, function () { return false; });
|
| 244 |
+
st.equal(returnCount, 0, 'iter1, before return()');
|
| 245 |
+
iter1['return']();
|
| 246 |
+
st.equal(returnCount, 1, 'iter1, after return()');
|
| 247 |
+
|
| 248 |
+
st.end();
|
| 249 |
+
});
|
| 250 |
+
|
| 251 |
+
t.test('262: test/built-ins/Iterator/prototype/drop/return-is-not-forwarded-after-exhaustion', { skip: !hasPropertyDescriptors }, function (st) {
|
| 252 |
+
var makeBadIterator = function makeBadIterator() {
|
| 253 |
+
return {
|
| 254 |
+
next: function next() {
|
| 255 |
+
return {
|
| 256 |
+
done: true,
|
| 257 |
+
value: undefined
|
| 258 |
+
};
|
| 259 |
+
},
|
| 260 |
+
'return': function () {
|
| 261 |
+
throw new SyntaxError();
|
| 262 |
+
}
|
| 263 |
+
};
|
| 264 |
+
};
|
| 265 |
+
|
| 266 |
+
var iter1 = filter(makeBadIterator(), function () { return true; });
|
| 267 |
+
st['throws'](
|
| 268 |
+
function () { iter1['return'](); },
|
| 269 |
+
SyntaxError,
|
| 270 |
+
'iter1, return() throws'
|
| 271 |
+
);
|
| 272 |
+
iter1.next();
|
| 273 |
+
iter1['return']();
|
| 274 |
+
|
| 275 |
+
// 3 filters (i wish i had pipeline)
|
| 276 |
+
var iter2 = filter(
|
| 277 |
+
filter(
|
| 278 |
+
filter(
|
| 279 |
+
makeBadIterator(),
|
| 280 |
+
function () { return true; }
|
| 281 |
+
),
|
| 282 |
+
function () { return true; }
|
| 283 |
+
),
|
| 284 |
+
function () { return true; }
|
| 285 |
+
);
|
| 286 |
+
st['throws']( // TODO
|
| 287 |
+
function () { iter2['return'](); },
|
| 288 |
+
SyntaxError,
|
| 289 |
+
'iter2, return() throws'
|
| 290 |
+
);
|
| 291 |
+
iter2.next();
|
| 292 |
+
iter2['return']();
|
| 293 |
+
|
| 294 |
+
st.end();
|
| 295 |
+
});
|
| 296 |
+
|
| 297 |
+
t.test('262: predicate-this', { skip: !hasSymbols }, function (st) {
|
| 298 |
+
var thisValue;
|
| 299 |
+
var iter = filter(
|
| 300 |
+
[1][Symbol.iterator](),
|
| 301 |
+
function () {
|
| 302 |
+
thisValue = this;
|
| 303 |
+
return true;
|
| 304 |
+
}
|
| 305 |
+
);
|
| 306 |
+
iter.next();
|
| 307 |
+
st.equal(thisValue, undefined, 'predicate this is undefined');
|
| 308 |
+
|
| 309 |
+
st.end();
|
| 310 |
+
});
|
| 311 |
+
|
| 312 |
+
t.test('262: predicate-returns-non-boolean', { skip: !hasSymbols }, function (st) {
|
| 313 |
+
// truthy non-boolean values should pass
|
| 314 |
+
testIterator(
|
| 315 |
+
filter([1, 2, 3][Symbol.iterator](), function () { return 1; }),
|
| 316 |
+
[1, 2, 3],
|
| 317 |
+
st,
|
| 318 |
+
'truthy number passes'
|
| 319 |
+
);
|
| 320 |
+
testIterator(
|
| 321 |
+
filter([1, 2, 3][Symbol.iterator](), function () { return 'yes'; }),
|
| 322 |
+
[1, 2, 3],
|
| 323 |
+
st,
|
| 324 |
+
'truthy string passes'
|
| 325 |
+
);
|
| 326 |
+
testIterator(
|
| 327 |
+
filter([1, 2, 3][Symbol.iterator](), function () { return {}; }),
|
| 328 |
+
[1, 2, 3],
|
| 329 |
+
st,
|
| 330 |
+
'truthy object passes'
|
| 331 |
+
);
|
| 332 |
+
|
| 333 |
+
// falsy non-boolean values should fail
|
| 334 |
+
testIterator(
|
| 335 |
+
filter([1, 2, 3][Symbol.iterator](), function () { return 0; }),
|
| 336 |
+
[],
|
| 337 |
+
st,
|
| 338 |
+
'falsy number fails'
|
| 339 |
+
);
|
| 340 |
+
testIterator(
|
| 341 |
+
filter([1, 2, 3][Symbol.iterator](), function () { return ''; }),
|
| 342 |
+
[],
|
| 343 |
+
st,
|
| 344 |
+
'falsy string fails'
|
| 345 |
+
);
|
| 346 |
+
testIterator(
|
| 347 |
+
filter([1, 2, 3][Symbol.iterator](), function () { return null; }),
|
| 348 |
+
[],
|
| 349 |
+
st,
|
| 350 |
+
'null fails'
|
| 351 |
+
);
|
| 352 |
+
|
| 353 |
+
st.end();
|
| 354 |
+
});
|
| 355 |
+
|
| 356 |
+
t.test('262: result is iterator', { skip: !hasSymbols }, function (st) {
|
| 357 |
+
var iterator = filter([1, 2][Symbol.iterator](), function () { return true; });
|
| 358 |
+
st.equal(typeof iterator.next, 'function', 'has next method');
|
| 359 |
+
st.equal(typeof iterator[Symbol.iterator], 'function', 'has Symbol.iterator method');
|
| 360 |
+
st.equal(iterator[Symbol.iterator](), iterator, 'Symbol.iterator returns itself');
|
| 361 |
+
|
| 362 |
+
st.end();
|
| 363 |
+
});
|
| 364 |
+
|
| 365 |
+
t.test('262: get next method only once', { skip: !hasPropertyDescriptors }, function (st) {
|
| 366 |
+
var nextGets = 0;
|
| 367 |
+
var testIter = {};
|
| 368 |
+
Object.defineProperty(testIter, 'next', {
|
| 369 |
+
get: function () {
|
| 370 |
+
nextGets += 1;
|
| 371 |
+
return function () {
|
| 372 |
+
return { done: true, value: undefined };
|
| 373 |
+
};
|
| 374 |
+
}
|
| 375 |
+
});
|
| 376 |
+
|
| 377 |
+
var iter = filter(testIter, function () { return true; });
|
| 378 |
+
st.equal(nextGets, 1, 'next retrieved once on creation');
|
| 379 |
+
iter.next();
|
| 380 |
+
st.equal(nextGets, 1, 'next not retrieved again');
|
| 381 |
+
|
| 382 |
+
st.end();
|
| 383 |
+
});
|
| 384 |
+
|
| 385 |
+
t.test('262: get next method throws', { skip: !hasPropertyDescriptors }, function (st) {
|
| 386 |
+
var testIter = {};
|
| 387 |
+
Object.defineProperty(testIter, 'next', {
|
| 388 |
+
get: function () {
|
| 389 |
+
throw new EvalError('next getter threw');
|
| 390 |
+
}
|
| 391 |
+
});
|
| 392 |
+
|
| 393 |
+
st['throws'](
|
| 394 |
+
function () { filter(testIter, function () { return true; }); },
|
| 395 |
+
EvalError,
|
| 396 |
+
'throws when getting next throws'
|
| 397 |
+
);
|
| 398 |
+
|
| 399 |
+
st.end();
|
| 400 |
+
});
|
| 401 |
+
|
| 402 |
+
t.test('262: next method returns non-object throws', function (st) {
|
| 403 |
+
var badIterator = {
|
| 404 |
+
next: function () {
|
| 405 |
+
return null;
|
| 406 |
+
}
|
| 407 |
+
};
|
| 408 |
+
|
| 409 |
+
var iter = filter(badIterator, function () { return true; });
|
| 410 |
+
st['throws'](function () { iter.next(); }, TypeError, 'throws when next returns null');
|
| 411 |
+
|
| 412 |
+
st.end();
|
| 413 |
+
});
|
| 414 |
+
|
| 415 |
+
t.test('262: next method returns throwing done', { skip: !hasPropertyDescriptors }, function (st) {
|
| 416 |
+
var throwingIterator = {
|
| 417 |
+
next: function () {
|
| 418 |
+
var result = { value: 1 };
|
| 419 |
+
Object.defineProperty(result, 'done', {
|
| 420 |
+
get: function () {
|
| 421 |
+
throw new EvalError('done getter threw');
|
| 422 |
+
}
|
| 423 |
+
});
|
| 424 |
+
return result;
|
| 425 |
+
}
|
| 426 |
+
};
|
| 427 |
+
|
| 428 |
+
var iter = filter(throwingIterator, function () { return true; });
|
| 429 |
+
st['throws'](function () { iter.next(); }, EvalError, 'throws when done getter throws');
|
| 430 |
+
|
| 431 |
+
st.end();
|
| 432 |
+
});
|
| 433 |
+
|
| 434 |
+
t.test('262: next method returns throwing value', { skip: !hasPropertyDescriptors }, function (st) {
|
| 435 |
+
var throwingIterator = {
|
| 436 |
+
next: function () {
|
| 437 |
+
var result = { done: false };
|
| 438 |
+
Object.defineProperty(result, 'value', {
|
| 439 |
+
get: function () {
|
| 440 |
+
throw new EvalError('value getter threw');
|
| 441 |
+
}
|
| 442 |
+
});
|
| 443 |
+
return result;
|
| 444 |
+
}
|
| 445 |
+
};
|
| 446 |
+
|
| 447 |
+
var iter = filter(throwingIterator, function () { return true; });
|
| 448 |
+
st['throws'](function () { iter.next(); }, EvalError, 'throws when value getter throws');
|
| 449 |
+
|
| 450 |
+
st.end();
|
| 451 |
+
});
|
| 452 |
+
|
| 453 |
+
t.test('262: next method throws', function (st) {
|
| 454 |
+
var throwingIterator = {
|
| 455 |
+
next: function () {
|
| 456 |
+
throw new EvalError('next threw');
|
| 457 |
+
}
|
| 458 |
+
};
|
| 459 |
+
|
| 460 |
+
var iter = filter(throwingIterator, function () { return true; });
|
| 461 |
+
st['throws'](function () { iter.next(); }, EvalError, 'throws error from next');
|
| 462 |
+
|
| 463 |
+
st.end();
|
| 464 |
+
});
|
| 465 |
+
|
| 466 |
+
t.test('262: iterator already exhausted', function (st) {
|
| 467 |
+
var testIter = {
|
| 468 |
+
next: function () {
|
| 469 |
+
return { done: true, value: undefined };
|
| 470 |
+
}
|
| 471 |
+
};
|
| 472 |
+
|
| 473 |
+
var predicateCalls = 0;
|
| 474 |
+
var iter = filter(testIter, function () {
|
| 475 |
+
predicateCalls += 1;
|
| 476 |
+
return true;
|
| 477 |
+
});
|
| 478 |
+
|
| 479 |
+
var result = iter.next();
|
| 480 |
+
st.equal(result.done, true, 'done is true');
|
| 481 |
+
st.equal(result.value, undefined, 'value is undefined');
|
| 482 |
+
st.equal(predicateCalls, 0, 'predicate not called for exhausted iterator');
|
| 483 |
+
|
| 484 |
+
st.end();
|
| 485 |
+
});
|
| 486 |
+
|
| 487 |
+
t.test('262: throws TypeError when generator is running', function (st) {
|
| 488 |
+
var reentrantIterator;
|
| 489 |
+
var testIter = {
|
| 490 |
+
next: function () {
|
| 491 |
+
reentrantIterator.next();
|
| 492 |
+
return { done: false, value: 1 };
|
| 493 |
+
}
|
| 494 |
+
};
|
| 495 |
+
|
| 496 |
+
reentrantIterator = filter(testIter, function () { return true; });
|
| 497 |
+
st['throws'](function () { reentrantIterator.next(); }, TypeError, 'throws on reentrant next()');
|
| 498 |
+
|
| 499 |
+
st.end();
|
| 500 |
+
});
|
| 501 |
+
|
| 502 |
+
t.test('262: exhaustion does not call return', function (st) {
|
| 503 |
+
var returnCalls = 0;
|
| 504 |
+
|
| 505 |
+
var testIter = {
|
| 506 |
+
next: function () {
|
| 507 |
+
return { done: true, value: undefined };
|
| 508 |
+
},
|
| 509 |
+
'return': function () {
|
| 510 |
+
returnCalls += 1;
|
| 511 |
+
return { done: true, value: undefined };
|
| 512 |
+
}
|
| 513 |
+
};
|
| 514 |
+
|
| 515 |
+
var iter = filter(testIter, function () { return true; });
|
| 516 |
+
iter.next();
|
| 517 |
+
st.equal(returnCalls, 0, 'return not called on exhaustion');
|
| 518 |
+
|
| 519 |
+
st.end();
|
| 520 |
+
});
|
| 521 |
+
},
|
| 522 |
+
index: function () {
|
| 523 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 524 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 525 |
+
|
| 526 |
+
t.end();
|
| 527 |
+
});
|
| 528 |
+
},
|
| 529 |
+
implementation: function () {
|
| 530 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 531 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 532 |
+
|
| 533 |
+
t.end();
|
| 534 |
+
});
|
| 535 |
+
},
|
| 536 |
+
shimmed: function () {
|
| 537 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 538 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 539 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 540 |
+
st.end();
|
| 541 |
+
});
|
| 542 |
+
|
| 543 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 544 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 545 |
+
et.end();
|
| 546 |
+
});
|
| 547 |
+
|
| 548 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 549 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 550 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 551 |
+
st.end();
|
| 552 |
+
});
|
| 553 |
+
|
| 554 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 555 |
+
|
| 556 |
+
t.end();
|
| 557 |
+
});
|
| 558 |
+
}
|
| 559 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.find.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var iterate = require('iterate-iterator');
|
| 13 |
+
|
| 14 |
+
var index = require('../Iterator.prototype.find');
|
| 15 |
+
var impl = require('../Iterator.prototype.find/implementation');
|
| 16 |
+
|
| 17 |
+
var fnName = 'find';
|
| 18 |
+
|
| 19 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 20 |
+
|
| 21 |
+
var testIterator = require('./helpers/testIterator');
|
| 22 |
+
|
| 23 |
+
module.exports = {
|
| 24 |
+
tests: function (find, name, t) {
|
| 25 |
+
t['throws'](
|
| 26 |
+
function () { return new find(); }, // eslint-disable-line new-cap
|
| 27 |
+
TypeError,
|
| 28 |
+
'`' + name + '` is not a constructor'
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 32 |
+
t['throws'](
|
| 33 |
+
function () { iterate(find(nonIterator, function () {})); },
|
| 34 |
+
TypeError,
|
| 35 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
var badNext = { next: nonIterator };
|
| 39 |
+
t['throws'](
|
| 40 |
+
function () { iterate(find(badNext, function () {})); },
|
| 41 |
+
TypeError,
|
| 42 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 43 |
+
);
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 47 |
+
t['throws'](
|
| 48 |
+
function () { find({ next: function () {} }, nonFunction); },
|
| 49 |
+
TypeError,
|
| 50 |
+
debug(nonFunction) + ' is not a function'
|
| 51 |
+
);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 55 |
+
var arr = [1, 2, 3];
|
| 56 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 57 |
+
|
| 58 |
+
st['throws'](
|
| 59 |
+
function () { return new find(iterator()); }, // eslint-disable-line new-cap
|
| 60 |
+
TypeError,
|
| 61 |
+
'`' + name + '` iterator is not a constructor'
|
| 62 |
+
);
|
| 63 |
+
st['throws'](
|
| 64 |
+
function () { return new find(iterator(), function () {}); }, // eslint-disable-line new-cap
|
| 65 |
+
TypeError,
|
| 66 |
+
'`' + name + '` iterator is not a constructor'
|
| 67 |
+
);
|
| 68 |
+
|
| 69 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 70 |
+
st.equal(find(iterator(), function () { return false; }), undefined, 'find for always-false');
|
| 71 |
+
st.equal(find(iterator(), function () { return true; }), 1, 'find for always-true');
|
| 72 |
+
st.equal(find(iterator(), function (x, i) { return x === 2 && i === 1; }), 2, 'find returns value for matching value/index');
|
| 73 |
+
|
| 74 |
+
st.test('test262: test/built-ins/Iterator/prototype/find/predicate-args', function (s2t) {
|
| 75 |
+
var assertionCount = 0;
|
| 76 |
+
var result = find(
|
| 77 |
+
['a', 'b', 'c'][Symbol.iterator](),
|
| 78 |
+
function (value, count) {
|
| 79 |
+
if (value === 'a') {
|
| 80 |
+
s2t.equal(count, 0);
|
| 81 |
+
} else if (value === 'b') {
|
| 82 |
+
s2t.equal(count, 1);
|
| 83 |
+
} else if (value === 'c') {
|
| 84 |
+
s2t.equal(count, 2);
|
| 85 |
+
} else {
|
| 86 |
+
s2t.fail('unexpected value');
|
| 87 |
+
}
|
| 88 |
+
assertionCount += 1;
|
| 89 |
+
return false;
|
| 90 |
+
}
|
| 91 |
+
);
|
| 92 |
+
s2t.equal(result, undefined, 'find returns undefined when none match');
|
| 93 |
+
s2t.equal(assertionCount, 3, 'predicate called three times');
|
| 94 |
+
|
| 95 |
+
s2t.end();
|
| 96 |
+
});
|
| 97 |
+
|
| 98 |
+
st.test('test262: test/built-ins/Iterator/prototype/find/predicate-this', function (s2t) {
|
| 99 |
+
var expectedThis = (function () { return this; }()); // eslint-disable-line no-invalid-this
|
| 100 |
+
var assertionCount = 0;
|
| 101 |
+
var result = find(
|
| 102 |
+
[0][Symbol.iterator](),
|
| 103 |
+
function () {
|
| 104 |
+
s2t.equal(this, expectedThis, 'predicate this is undefined'); // eslint-disable-line no-invalid-this
|
| 105 |
+
assertionCount += 1;
|
| 106 |
+
return true;
|
| 107 |
+
}
|
| 108 |
+
);
|
| 109 |
+
s2t.equal(result, 0);
|
| 110 |
+
s2t.equal(assertionCount, 1);
|
| 111 |
+
|
| 112 |
+
s2t.end();
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
st.test('test262: test/built-ins/Iterator/prototype/find/predicate-returns-truthy', function (s2t) {
|
| 116 |
+
var callCount = 0;
|
| 117 |
+
var returnCalled = false;
|
| 118 |
+
var values = [0, 1, 2];
|
| 119 |
+
var idx = 0;
|
| 120 |
+
var iter = {
|
| 121 |
+
next: function () {
|
| 122 |
+
if (idx < values.length) {
|
| 123 |
+
var val = values[idx];
|
| 124 |
+
idx += 1;
|
| 125 |
+
return { done: false, value: val };
|
| 126 |
+
}
|
| 127 |
+
return { done: true, value: undefined };
|
| 128 |
+
},
|
| 129 |
+
'return': function () {
|
| 130 |
+
returnCalled = true;
|
| 131 |
+
return { done: true, value: undefined };
|
| 132 |
+
}
|
| 133 |
+
};
|
| 134 |
+
var result = find(
|
| 135 |
+
iter,
|
| 136 |
+
function () {
|
| 137 |
+
callCount += 1;
|
| 138 |
+
return true;
|
| 139 |
+
}
|
| 140 |
+
);
|
| 141 |
+
s2t.equal(result, 0, 'find returns first value when predicate returns truthy');
|
| 142 |
+
s2t.equal(callCount, 1, 'predicate called once');
|
| 143 |
+
s2t.equal(returnCalled, true, 'iterator is closed');
|
| 144 |
+
|
| 145 |
+
s2t.end();
|
| 146 |
+
});
|
| 147 |
+
|
| 148 |
+
st.test('test262: test/built-ins/Iterator/prototype/find/predicate-returns-falsey', function (s2t) {
|
| 149 |
+
var result = find(
|
| 150 |
+
[0, 1, 2, 3, 4][Symbol.iterator](),
|
| 151 |
+
function () { return false; }
|
| 152 |
+
);
|
| 153 |
+
s2t.equal(result, undefined, 'find returns undefined when predicate always returns falsey');
|
| 154 |
+
|
| 155 |
+
s2t.end();
|
| 156 |
+
});
|
| 157 |
+
|
| 158 |
+
st.test('test262: test/built-ins/Iterator/prototype/find/predicate-returns-falsey-then-truthy', function (s2t) {
|
| 159 |
+
var callCount = 0;
|
| 160 |
+
var returnCalled = false;
|
| 161 |
+
var values = [0, 1, 2, 3, 4];
|
| 162 |
+
var idx = 0;
|
| 163 |
+
var iter = {
|
| 164 |
+
next: function () {
|
| 165 |
+
if (idx < values.length) {
|
| 166 |
+
var val = values[idx];
|
| 167 |
+
idx += 1;
|
| 168 |
+
return { done: false, value: val };
|
| 169 |
+
}
|
| 170 |
+
return { done: true, value: undefined };
|
| 171 |
+
},
|
| 172 |
+
'return': function () {
|
| 173 |
+
returnCalled = true;
|
| 174 |
+
return { done: true, value: undefined };
|
| 175 |
+
}
|
| 176 |
+
};
|
| 177 |
+
var result = find(
|
| 178 |
+
iter,
|
| 179 |
+
function (value) {
|
| 180 |
+
callCount += 1;
|
| 181 |
+
return value >= 3;
|
| 182 |
+
}
|
| 183 |
+
);
|
| 184 |
+
s2t.equal(result, 3, 'find returns matching value');
|
| 185 |
+
s2t.equal(callCount, 4, 'predicate called until truthy returned');
|
| 186 |
+
s2t.equal(returnCalled, true, 'iterator is closed');
|
| 187 |
+
|
| 188 |
+
s2t.end();
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
st.test('test262: test/built-ins/Iterator/prototype/find/predicate-returns-non-boolean', function (s2t) {
|
| 192 |
+
// truthy non-boolean values find the first element
|
| 193 |
+
s2t.equal(find([1, 2][Symbol.iterator](), function () { return 1; }), 1, 'truthy number');
|
| 194 |
+
s2t.equal(find([1, 2][Symbol.iterator](), function () { return 'yes'; }), 1, 'truthy string');
|
| 195 |
+
s2t.equal(find([1, 2][Symbol.iterator](), function () { return {}; }), 1, 'truthy object');
|
| 196 |
+
|
| 197 |
+
// falsy non-boolean values return undefined
|
| 198 |
+
s2t.equal(find([1][Symbol.iterator](), function () { return 0; }), undefined, 'falsy number');
|
| 199 |
+
s2t.equal(find([1][Symbol.iterator](), function () { return ''; }), undefined, 'falsy string');
|
| 200 |
+
s2t.equal(find([1][Symbol.iterator](), function () { return null; }), undefined, 'null');
|
| 201 |
+
|
| 202 |
+
s2t.end();
|
| 203 |
+
});
|
| 204 |
+
|
| 205 |
+
st.test('test262: test/built-ins/Iterator/prototype/find/predicate-throws', function (s2t) {
|
| 206 |
+
var returnCount = 0;
|
| 207 |
+
var testIter = {
|
| 208 |
+
next: function () {
|
| 209 |
+
return { done: false, value: 1 };
|
| 210 |
+
},
|
| 211 |
+
'return': function () {
|
| 212 |
+
returnCount += 1;
|
| 213 |
+
return { done: true };
|
| 214 |
+
}
|
| 215 |
+
};
|
| 216 |
+
|
| 217 |
+
var callbackCount = 0;
|
| 218 |
+
s2t['throws'](
|
| 219 |
+
function () {
|
| 220 |
+
find(testIter, function () {
|
| 221 |
+
callbackCount += 1;
|
| 222 |
+
throw new SyntaxError('predicate threw');
|
| 223 |
+
});
|
| 224 |
+
},
|
| 225 |
+
SyntaxError
|
| 226 |
+
);
|
| 227 |
+
s2t.equal(callbackCount, 1, 'predicate called once');
|
| 228 |
+
s2t.equal(returnCount, 1, 'iterator closed when predicate throws');
|
| 229 |
+
|
| 230 |
+
s2t.end();
|
| 231 |
+
});
|
| 232 |
+
|
| 233 |
+
st.test('test262: test/built-ins/Iterator/prototype/find/iterator-already-exhausted', function (s2t) {
|
| 234 |
+
var iter = [][Symbol.iterator]();
|
| 235 |
+
var callbackCount = 0;
|
| 236 |
+
var result = find(iter, function () {
|
| 237 |
+
callbackCount += 1;
|
| 238 |
+
return true;
|
| 239 |
+
});
|
| 240 |
+
s2t.equal(result, undefined, 'find returns undefined for empty iterator');
|
| 241 |
+
s2t.equal(callbackCount, 0, 'predicate not called');
|
| 242 |
+
|
| 243 |
+
s2t.end();
|
| 244 |
+
});
|
| 245 |
+
|
| 246 |
+
st.end();
|
| 247 |
+
});
|
| 248 |
+
},
|
| 249 |
+
index: function () {
|
| 250 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 251 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 252 |
+
|
| 253 |
+
t.end();
|
| 254 |
+
});
|
| 255 |
+
},
|
| 256 |
+
implementation: function () {
|
| 257 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 258 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 259 |
+
|
| 260 |
+
t.end();
|
| 261 |
+
});
|
| 262 |
+
},
|
| 263 |
+
shimmed: function () {
|
| 264 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 265 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 266 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 267 |
+
st.end();
|
| 268 |
+
});
|
| 269 |
+
|
| 270 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 271 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 272 |
+
et.end();
|
| 273 |
+
});
|
| 274 |
+
|
| 275 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 276 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 277 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 278 |
+
st.end();
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 282 |
+
|
| 283 |
+
t.end();
|
| 284 |
+
});
|
| 285 |
+
}
|
| 286 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.flatMap.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var iterate = require('iterate-iterator');
|
| 13 |
+
|
| 14 |
+
var StringToCodePoints = require('es-abstract/2025/StringToCodePoints');
|
| 15 |
+
|
| 16 |
+
var index = require('../Iterator.prototype.flatMap');
|
| 17 |
+
var impl = require('../Iterator.prototype.flatMap/implementation');
|
| 18 |
+
|
| 19 |
+
var fnName = 'flatMap';
|
| 20 |
+
|
| 21 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 22 |
+
|
| 23 |
+
var testIterator = require('./helpers/testIterator');
|
| 24 |
+
|
| 25 |
+
module.exports = {
|
| 26 |
+
tests: function (flatMap, name, t) {
|
| 27 |
+
t['throws'](
|
| 28 |
+
function () { return new flatMap(); }, // eslint-disable-line new-cap
|
| 29 |
+
TypeError,
|
| 30 |
+
'`' + name + '` is not a constructor'
|
| 31 |
+
);
|
| 32 |
+
|
| 33 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 34 |
+
t['throws'](
|
| 35 |
+
function () { iterate(flatMap(nonIterator, function () {})); },
|
| 36 |
+
TypeError,
|
| 37 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 38 |
+
);
|
| 39 |
+
|
| 40 |
+
var badNext = { next: nonIterator };
|
| 41 |
+
t['throws'](
|
| 42 |
+
function () { iterate(flatMap(badNext, function () {})); },
|
| 43 |
+
TypeError,
|
| 44 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 45 |
+
);
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 49 |
+
t['throws'](
|
| 50 |
+
function () { flatMap({ next: function () {} }, nonFunction); },
|
| 51 |
+
TypeError,
|
| 52 |
+
debug(nonFunction) + ' is not a function'
|
| 53 |
+
);
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 57 |
+
var arr = [1, 2, 3];
|
| 58 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 59 |
+
|
| 60 |
+
st['throws'](
|
| 61 |
+
function () { return new flatMap(iterator()); }, // eslint-disable-line new-cap
|
| 62 |
+
TypeError,
|
| 63 |
+
'`' + name + '` iterator is not a constructor'
|
| 64 |
+
);
|
| 65 |
+
st['throws'](
|
| 66 |
+
function () { return new flatMap(iterator(), function () {}); }, // eslint-disable-line new-cap
|
| 67 |
+
TypeError,
|
| 68 |
+
'`' + name + '` iterator is not a constructor'
|
| 69 |
+
);
|
| 70 |
+
|
| 71 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 72 |
+
|
| 73 |
+
var nonIterableFlatMap = flatMap(iterator(), function (x) { return x; });
|
| 74 |
+
st['throws'](
|
| 75 |
+
function () { nonIterableFlatMap.next(); },
|
| 76 |
+
TypeError,
|
| 77 |
+
'non-iterable return value throws'
|
| 78 |
+
);
|
| 79 |
+
|
| 80 |
+
forEach(v.strings, function (string) {
|
| 81 |
+
st['throws'](
|
| 82 |
+
function () { flatMap(iterator(), function () { return string; }).next(); },
|
| 83 |
+
TypeError,
|
| 84 |
+
'non-object return value throws even if iterable (' + debug(string) + ')'
|
| 85 |
+
);
|
| 86 |
+
|
| 87 |
+
testIterator(
|
| 88 |
+
flatMap(iterator(), function () { return Object(string); }),
|
| 89 |
+
[].concat(StringToCodePoints(string), StringToCodePoints(string), StringToCodePoints(string)),
|
| 90 |
+
st,
|
| 91 |
+
'boxed string (' + debug(string) + ')'
|
| 92 |
+
);
|
| 93 |
+
});
|
| 94 |
+
|
| 95 |
+
testIterator(flatMap(iterator(), function (x) { return [x][Symbol.iterator](); }), [1, 2, 3], st, 'identity mapper in array iterator');
|
| 96 |
+
testIterator(flatMap(iterator(), function (x) { return [2 * x][Symbol.iterator](); }), [2, 4, 6], st, 'doubler mapper in array iterator');
|
| 97 |
+
|
| 98 |
+
testIterator(flatMap(iterator(), function () { return []; }), [], st, 'empty mapper in nested array iterator');
|
| 99 |
+
testIterator(flatMap(iterator(), function (x) { return [[x, x + 1]][Symbol.iterator](); }), [[1, 2], [2, 3], [3, 4]], st, 'identity mapper in nested array iterator');
|
| 100 |
+
testIterator(flatMap(iterator(), function (x) { return [[2 * x, 2 * (x + 1)]][Symbol.iterator](); }), [[2, 4], [4, 6], [6, 8]], st, 'doubler mapper in nested array iterator');
|
| 101 |
+
|
| 102 |
+
testIterator(flatMap([0, 1, 2, 3][Symbol.iterator](), function (value) {
|
| 103 |
+
var result = [];
|
| 104 |
+
for (var i = 0; i < value; ++i) {
|
| 105 |
+
result.push(value);
|
| 106 |
+
}
|
| 107 |
+
return result;
|
| 108 |
+
}), [1, 2, 2, 3, 3, 3], st, 'test262: test/built-ins/Iterator/prototype/flatMap/flattens-iteratable');
|
| 109 |
+
|
| 110 |
+
testIterator(flatMap([0, 1, 2, 3][Symbol.iterator](), function (value) {
|
| 111 |
+
var i = 0;
|
| 112 |
+
return {
|
| 113 |
+
next: function () {
|
| 114 |
+
if (i < value) {
|
| 115 |
+
i += 1;
|
| 116 |
+
return {
|
| 117 |
+
value: value,
|
| 118 |
+
done: false
|
| 119 |
+
};
|
| 120 |
+
}
|
| 121 |
+
return {
|
| 122 |
+
value: undefined,
|
| 123 |
+
done: true
|
| 124 |
+
};
|
| 125 |
+
|
| 126 |
+
}
|
| 127 |
+
};
|
| 128 |
+
}), [1, 2, 2, 3, 3, 3], st, 'test262: test/built-ins/Iterator/prototype/flatMap/flattens-iterator');
|
| 129 |
+
|
| 130 |
+
testIterator(flatMap([0][Symbol.iterator](), function () {
|
| 131 |
+
var n = [0, 1, 2][Symbol.iterator]();
|
| 132 |
+
|
| 133 |
+
var ret = {
|
| 134 |
+
next: function next() {
|
| 135 |
+
return n.next();
|
| 136 |
+
}
|
| 137 |
+
};
|
| 138 |
+
ret[Symbol.iterator] = null;
|
| 139 |
+
return ret;
|
| 140 |
+
}), [0, 1, 2], st, 'test262: test/built-ins/Iterator/prototype/flatMap/iterable-to-iterator-fallback');
|
| 141 |
+
|
| 142 |
+
var counts = [];
|
| 143 |
+
testIterator(flatMap(['a', 'b', 'c', 'd', 'e'][Symbol.iterator](), function (value, count) {
|
| 144 |
+
counts.push(count);
|
| 145 |
+
|
| 146 |
+
if (value === 'a' || value === 'b') {
|
| 147 |
+
return [0];
|
| 148 |
+
}
|
| 149 |
+
if (value === 'c') {
|
| 150 |
+
return [1, 2];
|
| 151 |
+
}
|
| 152 |
+
if (value === 'd') {
|
| 153 |
+
return [3, 4, 5];
|
| 154 |
+
}
|
| 155 |
+
if (value === 'e') {
|
| 156 |
+
return [6, 7, 8, 9];
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
return st.fail('got unexpected value: ' + debug(v));
|
| 160 |
+
}), [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], st, 'test262: test/built-ins/Iterator/prototype/flatMap/mapper-args');
|
| 161 |
+
st.deepEqual(counts, [0, 1, 2, 3, 4], 'count values are as expected');
|
| 162 |
+
|
| 163 |
+
st.test('return protocol', function (s2t) {
|
| 164 |
+
var returnCount = 0;
|
| 165 |
+
|
| 166 |
+
var iter = flatMap([0][Symbol.iterator](), function () {
|
| 167 |
+
return {
|
| 168 |
+
next: function next() {
|
| 169 |
+
return {
|
| 170 |
+
done: false,
|
| 171 |
+
value: 1
|
| 172 |
+
};
|
| 173 |
+
},
|
| 174 |
+
'return': function () {
|
| 175 |
+
returnCount += 1;
|
| 176 |
+
return {};
|
| 177 |
+
}
|
| 178 |
+
};
|
| 179 |
+
});
|
| 180 |
+
s2t.equal(returnCount, 0, '`return` is not called yet');
|
| 181 |
+
|
| 182 |
+
s2t.deepEqual(iter.next(), {
|
| 183 |
+
done: false,
|
| 184 |
+
value: 1
|
| 185 |
+
});
|
| 186 |
+
|
| 187 |
+
s2t.equal(returnCount, 0, '`return` is not called after first yield');
|
| 188 |
+
|
| 189 |
+
iter['return']();
|
| 190 |
+
s2t.equal(returnCount, 1, '`return` is called when iterator return is called');
|
| 191 |
+
|
| 192 |
+
iter['return']();
|
| 193 |
+
s2t.equal(returnCount, 1, '`return` is not called again when iterator return is called again');
|
| 194 |
+
|
| 195 |
+
s2t.end();
|
| 196 |
+
});
|
| 197 |
+
|
| 198 |
+
st.end();
|
| 199 |
+
});
|
| 200 |
+
},
|
| 201 |
+
index: function () {
|
| 202 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 203 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 204 |
+
|
| 205 |
+
t.end();
|
| 206 |
+
});
|
| 207 |
+
},
|
| 208 |
+
implementation: function () {
|
| 209 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 210 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 211 |
+
|
| 212 |
+
t.end();
|
| 213 |
+
});
|
| 214 |
+
},
|
| 215 |
+
shimmed: function () {
|
| 216 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 217 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 218 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 219 |
+
st.end();
|
| 220 |
+
});
|
| 221 |
+
|
| 222 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 223 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 224 |
+
et.end();
|
| 225 |
+
});
|
| 226 |
+
|
| 227 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 228 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 229 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 230 |
+
st.end();
|
| 231 |
+
});
|
| 232 |
+
|
| 233 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 234 |
+
|
| 235 |
+
t.end();
|
| 236 |
+
});
|
| 237 |
+
}
|
| 238 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.forEach.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEachNormal = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var iterate = require('iterate-iterator');
|
| 13 |
+
|
| 14 |
+
var index = require('../Iterator.prototype.forEach');
|
| 15 |
+
var impl = require('../Iterator.prototype.forEach/implementation');
|
| 16 |
+
|
| 17 |
+
var fnName = 'forEach';
|
| 18 |
+
|
| 19 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 20 |
+
|
| 21 |
+
var testIterator = require('./helpers/testIterator');
|
| 22 |
+
|
| 23 |
+
module.exports = {
|
| 24 |
+
tests: function (forEach, name, t) {
|
| 25 |
+
t['throws'](
|
| 26 |
+
function () { return new forEach(); }, // eslint-disable-line new-cap
|
| 27 |
+
TypeError,
|
| 28 |
+
'`' + name + '` is not a constructor'
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
forEachNormal(v.primitives.concat(v.objects), function (nonIterator) {
|
| 32 |
+
t['throws'](
|
| 33 |
+
function () { iterate(forEach(nonIterator, function () {})); },
|
| 34 |
+
TypeError,
|
| 35 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
var badNext = { next: nonIterator };
|
| 39 |
+
t['throws'](
|
| 40 |
+
function () { iterate(forEach(badNext, function () {})); },
|
| 41 |
+
TypeError,
|
| 42 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 43 |
+
);
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
forEachNormal(v.nonFunctions, function (nonFunction) {
|
| 47 |
+
t['throws'](
|
| 48 |
+
function () { forEach({ next: function () {} }, nonFunction); },
|
| 49 |
+
TypeError,
|
| 50 |
+
debug(nonFunction) + ' is not a function'
|
| 51 |
+
);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 55 |
+
var arr = [1, 2, 3];
|
| 56 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 57 |
+
|
| 58 |
+
st['throws'](
|
| 59 |
+
function () { return new forEach(iterator()); }, // eslint-disable-line new-cap
|
| 60 |
+
TypeError,
|
| 61 |
+
'`' + name + '` iterator is not a constructor'
|
| 62 |
+
);
|
| 63 |
+
st['throws'](
|
| 64 |
+
function () { return new forEach(iterator(), function () {}); }, // eslint-disable-line new-cap
|
| 65 |
+
TypeError,
|
| 66 |
+
'`' + name + '` iterator is not a constructor'
|
| 67 |
+
);
|
| 68 |
+
|
| 69 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 70 |
+
|
| 71 |
+
var results = [];
|
| 72 |
+
var ret = forEach(
|
| 73 |
+
iterator(),
|
| 74 |
+
function (x, i) {
|
| 75 |
+
|
| 76 |
+
results.push({ value: x, count: i, 'this': this, args: arguments.length });
|
| 77 |
+
}
|
| 78 |
+
);
|
| 79 |
+
|
| 80 |
+
st.equal(ret, undefined, 'returns undefined');
|
| 81 |
+
|
| 82 |
+
st.deepEqual(
|
| 83 |
+
results,
|
| 84 |
+
[
|
| 85 |
+
{ value: 1, count: 0, 'this': undefined, args: 2 },
|
| 86 |
+
{ value: 2, count: 1, 'this': undefined, args: 2 },
|
| 87 |
+
{ value: 3, count: 2, 'this': undefined, args: 2 }
|
| 88 |
+
],
|
| 89 |
+
'forEach callback receives the expected values'
|
| 90 |
+
);
|
| 91 |
+
|
| 92 |
+
st.test('test262: test/built-ins/Iterator/prototype/forEach/fn-args', function (s2t) {
|
| 93 |
+
var assertionCount = 0;
|
| 94 |
+
var result = forEach(
|
| 95 |
+
['a', 'b', 'c'][Symbol.iterator](),
|
| 96 |
+
function (value, count) {
|
| 97 |
+
if (value === 'a') {
|
| 98 |
+
s2t.equal(count, 0);
|
| 99 |
+
} else if (value === 'b') {
|
| 100 |
+
s2t.equal(count, 1);
|
| 101 |
+
} else if (value === 'c') {
|
| 102 |
+
s2t.equal(count, 2);
|
| 103 |
+
} else {
|
| 104 |
+
s2t.fail('unexpected value');
|
| 105 |
+
}
|
| 106 |
+
assertionCount += 1;
|
| 107 |
+
}
|
| 108 |
+
);
|
| 109 |
+
s2t.equal(result, undefined, 'forEach returns undefined');
|
| 110 |
+
s2t.equal(assertionCount, 3, 'callback called three times');
|
| 111 |
+
|
| 112 |
+
s2t.end();
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
st.test('test262: test/built-ins/Iterator/prototype/forEach/fn-this', function (s2t) {
|
| 116 |
+
var expectedThis = (function () { return this; }()); // eslint-disable-line no-invalid-this
|
| 117 |
+
var assertionCount = 0;
|
| 118 |
+
var result = forEach(
|
| 119 |
+
[0][Symbol.iterator](),
|
| 120 |
+
function () {
|
| 121 |
+
s2t.equal(this, expectedThis, 'fn this is undefined'); // eslint-disable-line no-invalid-this
|
| 122 |
+
assertionCount += 1;
|
| 123 |
+
}
|
| 124 |
+
);
|
| 125 |
+
s2t.equal(result, undefined);
|
| 126 |
+
s2t.equal(assertionCount, 1);
|
| 127 |
+
|
| 128 |
+
s2t.end();
|
| 129 |
+
});
|
| 130 |
+
|
| 131 |
+
st.test('test262: test/built-ins/Iterator/prototype/forEach/fn-called-for-each-yielded-value', function (s2t) {
|
| 132 |
+
var values = [];
|
| 133 |
+
forEach(
|
| 134 |
+
[1, 2, 3, 4, 5][Symbol.iterator](),
|
| 135 |
+
function (value) { values.push(value); }
|
| 136 |
+
);
|
| 137 |
+
s2t.deepEqual(values, [1, 2, 3, 4, 5], 'callback called for each value');
|
| 138 |
+
|
| 139 |
+
s2t.end();
|
| 140 |
+
});
|
| 141 |
+
|
| 142 |
+
st.test('test262: test/built-ins/Iterator/prototype/forEach/fn-throws', function (s2t) {
|
| 143 |
+
var returnCount = 0;
|
| 144 |
+
var testIter = {
|
| 145 |
+
next: function () {
|
| 146 |
+
return { done: false, value: 1 };
|
| 147 |
+
},
|
| 148 |
+
'return': function () {
|
| 149 |
+
returnCount += 1;
|
| 150 |
+
return { done: true };
|
| 151 |
+
}
|
| 152 |
+
};
|
| 153 |
+
|
| 154 |
+
var callbackCount = 0;
|
| 155 |
+
s2t['throws'](
|
| 156 |
+
function () {
|
| 157 |
+
forEach(testIter, function () {
|
| 158 |
+
callbackCount += 1;
|
| 159 |
+
throw new SyntaxError('callback threw');
|
| 160 |
+
});
|
| 161 |
+
},
|
| 162 |
+
SyntaxError
|
| 163 |
+
);
|
| 164 |
+
s2t.equal(callbackCount, 1, 'callback called once');
|
| 165 |
+
s2t.equal(returnCount, 1, 'iterator closed when callback throws');
|
| 166 |
+
|
| 167 |
+
s2t.end();
|
| 168 |
+
});
|
| 169 |
+
|
| 170 |
+
st.test('test262: test/built-ins/Iterator/prototype/forEach/iterator-already-exhausted', function (s2t) {
|
| 171 |
+
var iter = [][Symbol.iterator]();
|
| 172 |
+
var callbackCount = 0;
|
| 173 |
+
var result = forEach(iter, function () {
|
| 174 |
+
callbackCount += 1;
|
| 175 |
+
});
|
| 176 |
+
s2t.equal(result, undefined, 'forEach returns undefined for empty iterator');
|
| 177 |
+
s2t.equal(callbackCount, 0, 'callback not called');
|
| 178 |
+
|
| 179 |
+
s2t.end();
|
| 180 |
+
});
|
| 181 |
+
|
| 182 |
+
st.test('test262: test/built-ins/Iterator/prototype/forEach/result-is-undefined', function (s2t) {
|
| 183 |
+
var result = forEach(
|
| 184 |
+
[1, 2, 3][Symbol.iterator](),
|
| 185 |
+
function () {}
|
| 186 |
+
);
|
| 187 |
+
s2t.equal(result, undefined, 'forEach returns undefined');
|
| 188 |
+
|
| 189 |
+
s2t.end();
|
| 190 |
+
});
|
| 191 |
+
|
| 192 |
+
st.end();
|
| 193 |
+
});
|
| 194 |
+
},
|
| 195 |
+
index: function () {
|
| 196 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 197 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 198 |
+
|
| 199 |
+
t.end();
|
| 200 |
+
});
|
| 201 |
+
},
|
| 202 |
+
implementation: function () {
|
| 203 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 204 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 205 |
+
|
| 206 |
+
t.end();
|
| 207 |
+
});
|
| 208 |
+
},
|
| 209 |
+
shimmed: function () {
|
| 210 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 211 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 212 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 213 |
+
st.end();
|
| 214 |
+
});
|
| 215 |
+
|
| 216 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 217 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 218 |
+
et.end();
|
| 219 |
+
});
|
| 220 |
+
|
| 221 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 222 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 223 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 224 |
+
st.end();
|
| 225 |
+
});
|
| 226 |
+
|
| 227 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 228 |
+
|
| 229 |
+
t.end();
|
| 230 |
+
});
|
| 231 |
+
}
|
| 232 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var hasSymbols = require('has-symbols')();
|
| 6 |
+
var hasToStringTag = require('has-tostringtag');
|
| 7 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 8 |
+
var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();
|
| 9 |
+
|
| 10 |
+
var index = require('../Iterator.prototype');
|
| 11 |
+
var impl = require('../Iterator.prototype/implementation');
|
| 12 |
+
|
| 13 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 14 |
+
|
| 15 |
+
var $Iterator = require('../Iterator/implementation');
|
| 16 |
+
|
| 17 |
+
module.exports = {
|
| 18 |
+
tests: function (proto, name, t) {
|
| 19 |
+
t.notEqual(proto, null, 'is not null');
|
| 20 |
+
t.equal(typeof proto, 'object', 'is an object');
|
| 21 |
+
|
| 22 |
+
t.test('Symbol.iterator', { skip: !hasSymbols }, function (st) {
|
| 23 |
+
st.equal(typeof proto[Symbol.iterator], 'function', 'has a `Symbol.iterator` method');
|
| 24 |
+
st.equal(
|
| 25 |
+
proto[Symbol.iterator].name,
|
| 26 |
+
'[Symbol.iterator]',
|
| 27 |
+
'has name "[Symbol.iterator]"',
|
| 28 |
+
{ skip: functionsHaveNames && !functionsHaveConfigurableNames }
|
| 29 |
+
);
|
| 30 |
+
st.equal(proto[Symbol.iterator](), proto, 'function returns proto');
|
| 31 |
+
st.equal(proto[Symbol.iterator].call($Iterator), $Iterator, 'function returns receiver');
|
| 32 |
+
|
| 33 |
+
st.end();
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
t.test(
|
| 37 |
+
'Symbol.toStringTag',
|
| 38 |
+
{ skip: !hasToStringTag || 'temporarily skipped pending https://bugs.chromium.org/p/chromium/issues/detail?id=1477372' },
|
| 39 |
+
function (st) {
|
| 40 |
+
st.equal(proto[Symbol.toStringTag], 'Iterator', 'has a `Symbol.toStringTag` property');
|
| 41 |
+
|
| 42 |
+
st.end();
|
| 43 |
+
}
|
| 44 |
+
);
|
| 45 |
+
},
|
| 46 |
+
index: function () {
|
| 47 |
+
test('Iterator.prototype: index', function (t) {
|
| 48 |
+
module.exports.tests(index, 'Iterator.prototype', t);
|
| 49 |
+
|
| 50 |
+
t.end();
|
| 51 |
+
});
|
| 52 |
+
},
|
| 53 |
+
implementation: function () {
|
| 54 |
+
test('Iterator.prototype: implementation', function (t) {
|
| 55 |
+
module.exports.tests(impl, 'Iterator.prototype', t);
|
| 56 |
+
|
| 57 |
+
t.end();
|
| 58 |
+
});
|
| 59 |
+
},
|
| 60 |
+
shimmed: function () {
|
| 61 |
+
test('Iterator.prototype: shimmed', function (t) {
|
| 62 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 63 |
+
et.equal(false, isEnumerable.call(Iterator, 'prototype'), 'Iterator.prototype is not enumerable');
|
| 64 |
+
et.end();
|
| 65 |
+
});
|
| 66 |
+
|
| 67 |
+
module.exports.tests(Iterator.prototype, 'Iterator.prototype', t);
|
| 68 |
+
|
| 69 |
+
t.end();
|
| 70 |
+
});
|
| 71 |
+
}
|
| 72 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.map.js
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 13 |
+
var generators = require('make-generator-function')();
|
| 14 |
+
var iterate = require('iterate-iterator');
|
| 15 |
+
|
| 16 |
+
var index = require('../Iterator.prototype.map');
|
| 17 |
+
var impl = require('../Iterator.prototype.map/implementation');
|
| 18 |
+
|
| 19 |
+
var fnName = 'map';
|
| 20 |
+
|
| 21 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 22 |
+
|
| 23 |
+
var testIterator = require('./helpers/testIterator');
|
| 24 |
+
|
| 25 |
+
module.exports = {
|
| 26 |
+
tests: function (map, name, t) {
|
| 27 |
+
t['throws'](
|
| 28 |
+
function () { return new map(); }, // eslint-disable-line new-cap
|
| 29 |
+
TypeError,
|
| 30 |
+
'`' + name + '` itself is not a constructor'
|
| 31 |
+
);
|
| 32 |
+
|
| 33 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 34 |
+
t['throws'](
|
| 35 |
+
function () { iterate(map(nonIterator, function () {})); },
|
| 36 |
+
TypeError,
|
| 37 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 38 |
+
);
|
| 39 |
+
|
| 40 |
+
var badNext = { next: nonIterator };
|
| 41 |
+
t['throws'](
|
| 42 |
+
function () { iterate(map(badNext, function () {})); },
|
| 43 |
+
TypeError,
|
| 44 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 45 |
+
);
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 49 |
+
t['throws'](
|
| 50 |
+
function () { map({ next: function () {} }, nonFunction); },
|
| 51 |
+
TypeError,
|
| 52 |
+
debug(nonFunction) + ' is not a function'
|
| 53 |
+
);
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
var sentinel = {};
|
| 57 |
+
var done = false;
|
| 58 |
+
var fakeIterator = {
|
| 59 |
+
next: function () {
|
| 60 |
+
try {
|
| 61 |
+
return {
|
| 62 |
+
done: !!done,
|
| 63 |
+
value: sentinel
|
| 64 |
+
};
|
| 65 |
+
} finally {
|
| 66 |
+
done = done === false ? null : true;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
};
|
| 70 |
+
var result = {};
|
| 71 |
+
testIterator(
|
| 72 |
+
map(fakeIterator, function (x, i) {
|
| 73 |
+
result.value = x;
|
| 74 |
+
result.counter = i;
|
| 75 |
+
result.receiver = this;
|
| 76 |
+
result.args = arguments.length;
|
| 77 |
+
return fakeIterator;
|
| 78 |
+
}),
|
| 79 |
+
[fakeIterator, fakeIterator],
|
| 80 |
+
t,
|
| 81 |
+
'fake iterator, mapped, runs as expected'
|
| 82 |
+
);
|
| 83 |
+
t.deepEqual(
|
| 84 |
+
result,
|
| 85 |
+
{ value: sentinel, counter: 1, receiver: undefined, args: 2 },
|
| 86 |
+
'callback is called with the correct arguments'
|
| 87 |
+
);
|
| 88 |
+
|
| 89 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 90 |
+
var arr = [1, 2, 3];
|
| 91 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 92 |
+
|
| 93 |
+
st['throws'](
|
| 94 |
+
function () { return new map(iterator()); }, // eslint-disable-line new-cap
|
| 95 |
+
TypeError,
|
| 96 |
+
'`' + name + '` iterator is not a constructor'
|
| 97 |
+
);
|
| 98 |
+
st['throws'](
|
| 99 |
+
function () { return new map(iterator(), function () {}); }, // eslint-disable-line new-cap
|
| 100 |
+
TypeError,
|
| 101 |
+
'`' + name + '` iterator is not a constructor'
|
| 102 |
+
);
|
| 103 |
+
|
| 104 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 105 |
+
testIterator(map(iterator(), function (x) { return x; }), [1, 2, 3], st, 'identity mapper');
|
| 106 |
+
testIterator(map(iterator(), function (x) { return 2 * x; }), [2, 4, 6], st, 'doubler mapper');
|
| 107 |
+
|
| 108 |
+
st.test('generators', { skip: generators.length === 0 }, function (s2t) {
|
| 109 |
+
forEach(generators, function (gen) {
|
| 110 |
+
s2t.doesNotThrow(
|
| 111 |
+
function () { map(gen(), function () {}); },
|
| 112 |
+
'generator function ' + debug(gen) + ' does not need to be from-wrapped first'
|
| 113 |
+
);
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
s2t.end();
|
| 117 |
+
});
|
| 118 |
+
|
| 119 |
+
st.test('262: mapper-this', function (s2t) {
|
| 120 |
+
var thisValue;
|
| 121 |
+
var iter = map(
|
| 122 |
+
[1][Symbol.iterator](),
|
| 123 |
+
function () {
|
| 124 |
+
thisValue = this;
|
| 125 |
+
return 42;
|
| 126 |
+
}
|
| 127 |
+
);
|
| 128 |
+
iter.next();
|
| 129 |
+
s2t.equal(thisValue, undefined, 'mapper this is undefined in sloppy mode');
|
| 130 |
+
|
| 131 |
+
s2t.end();
|
| 132 |
+
});
|
| 133 |
+
|
| 134 |
+
st.test('262: result is iterator', function (s2t) {
|
| 135 |
+
var mappedIter = map([1, 2][Symbol.iterator](), function (x) { return x; });
|
| 136 |
+
s2t.equal(typeof mappedIter.next, 'function', 'has next method');
|
| 137 |
+
s2t.equal(typeof mappedIter[Symbol.iterator], 'function', 'has Symbol.iterator method');
|
| 138 |
+
s2t.equal(mappedIter[Symbol.iterator](), mappedIter, 'Symbol.iterator returns itself');
|
| 139 |
+
|
| 140 |
+
s2t.end();
|
| 141 |
+
});
|
| 142 |
+
|
| 143 |
+
st.test('262: get next method only once', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 144 |
+
var nextGets = 0;
|
| 145 |
+
var testIter = {
|
| 146 |
+
next: function () {
|
| 147 |
+
return { done: true, value: undefined };
|
| 148 |
+
}
|
| 149 |
+
};
|
| 150 |
+
Object.defineProperty(testIter, 'next', {
|
| 151 |
+
get: function () {
|
| 152 |
+
nextGets += 1;
|
| 153 |
+
return function () {
|
| 154 |
+
return { done: true, value: undefined };
|
| 155 |
+
};
|
| 156 |
+
}
|
| 157 |
+
});
|
| 158 |
+
|
| 159 |
+
var iter = map(testIter, function (x) { return x; });
|
| 160 |
+
s2t.equal(nextGets, 1, 'next retrieved once on creation');
|
| 161 |
+
iter.next();
|
| 162 |
+
s2t.equal(nextGets, 1, 'next not retrieved again');
|
| 163 |
+
|
| 164 |
+
s2t.end();
|
| 165 |
+
});
|
| 166 |
+
|
| 167 |
+
st.test('262: get next method throws', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 168 |
+
var testIter = {};
|
| 169 |
+
Object.defineProperty(testIter, 'next', {
|
| 170 |
+
get: function () {
|
| 171 |
+
throw new EvalError('next getter threw');
|
| 172 |
+
}
|
| 173 |
+
});
|
| 174 |
+
|
| 175 |
+
s2t['throws'](
|
| 176 |
+
function () { map(testIter, function () {}); },
|
| 177 |
+
EvalError,
|
| 178 |
+
'throws when getting next throws'
|
| 179 |
+
);
|
| 180 |
+
|
| 181 |
+
s2t.end();
|
| 182 |
+
});
|
| 183 |
+
|
| 184 |
+
st.test('262: next method returns non-object throws', function (s2t) {
|
| 185 |
+
var badIterator = {
|
| 186 |
+
next: function () {
|
| 187 |
+
return null;
|
| 188 |
+
}
|
| 189 |
+
};
|
| 190 |
+
|
| 191 |
+
var iter = map(badIterator, function (x) { return x; });
|
| 192 |
+
s2t['throws'](function () { iter.next(); }, TypeError, 'throws when next returns null');
|
| 193 |
+
|
| 194 |
+
var badIterator2 = {
|
| 195 |
+
next: function () {
|
| 196 |
+
return 42;
|
| 197 |
+
}
|
| 198 |
+
};
|
| 199 |
+
|
| 200 |
+
var iter2 = map(badIterator2, function (x) { return x; });
|
| 201 |
+
s2t['throws'](function () { iter2.next(); }, TypeError, 'throws when next returns number');
|
| 202 |
+
|
| 203 |
+
s2t.end();
|
| 204 |
+
});
|
| 205 |
+
|
| 206 |
+
st.test('262: next method returns throwing done', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 207 |
+
var throwingIterator = {
|
| 208 |
+
next: function () {
|
| 209 |
+
var iterResult = { value: 1 };
|
| 210 |
+
Object.defineProperty(iterResult, 'done', {
|
| 211 |
+
get: function () {
|
| 212 |
+
throw new EvalError('done getter threw');
|
| 213 |
+
}
|
| 214 |
+
});
|
| 215 |
+
return iterResult;
|
| 216 |
+
}
|
| 217 |
+
};
|
| 218 |
+
|
| 219 |
+
var iter = map(throwingIterator, function (x) { return x; });
|
| 220 |
+
s2t['throws'](function () { iter.next(); }, EvalError, 'throws when done getter throws');
|
| 221 |
+
|
| 222 |
+
s2t.end();
|
| 223 |
+
});
|
| 224 |
+
|
| 225 |
+
st.test('262: next method returns throwing value', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 226 |
+
var throwingIterator = {
|
| 227 |
+
next: function () {
|
| 228 |
+
var iterResult = { done: false };
|
| 229 |
+
Object.defineProperty(iterResult, 'value', {
|
| 230 |
+
get: function () {
|
| 231 |
+
throw new EvalError('value getter threw');
|
| 232 |
+
}
|
| 233 |
+
});
|
| 234 |
+
return iterResult;
|
| 235 |
+
}
|
| 236 |
+
};
|
| 237 |
+
|
| 238 |
+
var iter = map(throwingIterator, function (x) { return x; });
|
| 239 |
+
s2t['throws'](function () { iter.next(); }, EvalError, 'throws when value getter throws');
|
| 240 |
+
|
| 241 |
+
s2t.end();
|
| 242 |
+
});
|
| 243 |
+
|
| 244 |
+
st.test('262: next method throws', function (s2t) {
|
| 245 |
+
var throwingIterator = {
|
| 246 |
+
next: function () {
|
| 247 |
+
throw new EvalError('next threw');
|
| 248 |
+
}
|
| 249 |
+
};
|
| 250 |
+
|
| 251 |
+
var iter = map(throwingIterator, function (x) { return x; });
|
| 252 |
+
s2t['throws'](function () { iter.next(); }, EvalError, 'throws error from next');
|
| 253 |
+
|
| 254 |
+
s2t.end();
|
| 255 |
+
});
|
| 256 |
+
|
| 257 |
+
st.test('262: mapper throws', function (s2t) {
|
| 258 |
+
var returnCalls = 0;
|
| 259 |
+
|
| 260 |
+
var testIter = {
|
| 261 |
+
next: function () {
|
| 262 |
+
return { done: false, value: 1 };
|
| 263 |
+
},
|
| 264 |
+
'return': function () {
|
| 265 |
+
returnCalls += 1;
|
| 266 |
+
return { done: true, value: undefined };
|
| 267 |
+
}
|
| 268 |
+
};
|
| 269 |
+
|
| 270 |
+
var iter = map(testIter, function () {
|
| 271 |
+
throw new SyntaxError('mapper threw');
|
| 272 |
+
});
|
| 273 |
+
|
| 274 |
+
s2t['throws'](function () { iter.next(); }, SyntaxError, 'throws error from mapper');
|
| 275 |
+
s2t.equal(returnCalls, 1, 'return called on underlying iterator');
|
| 276 |
+
|
| 277 |
+
s2t.end();
|
| 278 |
+
});
|
| 279 |
+
|
| 280 |
+
st.test('262: mapper throws then closing iterator also throws', function (s2t) {
|
| 281 |
+
var testIter = {
|
| 282 |
+
next: function () {
|
| 283 |
+
return { done: false, value: 1 };
|
| 284 |
+
},
|
| 285 |
+
'return': function () {
|
| 286 |
+
throw new EvalError('return threw');
|
| 287 |
+
}
|
| 288 |
+
};
|
| 289 |
+
|
| 290 |
+
var iter = map(testIter, function () {
|
| 291 |
+
throw new SyntaxError('mapper threw');
|
| 292 |
+
});
|
| 293 |
+
|
| 294 |
+
s2t['throws'](function () { iter.next(); }, SyntaxError, 'mapper exception wins over return exception');
|
| 295 |
+
|
| 296 |
+
s2t.end();
|
| 297 |
+
});
|
| 298 |
+
|
| 299 |
+
st.test('262: get return method throws', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 300 |
+
var badIterator = {
|
| 301 |
+
next: function () {
|
| 302 |
+
return { done: false, value: 1 };
|
| 303 |
+
}
|
| 304 |
+
};
|
| 305 |
+
Object.defineProperty(badIterator, 'return', {
|
| 306 |
+
get: function () {
|
| 307 |
+
throw new SyntaxError('return getter threw');
|
| 308 |
+
}
|
| 309 |
+
});
|
| 310 |
+
|
| 311 |
+
var iter = map(badIterator, function (x) { return x; });
|
| 312 |
+
iter.next();
|
| 313 |
+
|
| 314 |
+
s2t['throws'](function () { iter['return'](); }, SyntaxError, 'throws error from return getter');
|
| 315 |
+
|
| 316 |
+
s2t.end();
|
| 317 |
+
});
|
| 318 |
+
|
| 319 |
+
st.test('262: return is forwarded to underlying iterator', function (s2t) {
|
| 320 |
+
var returnCalls = 0;
|
| 321 |
+
|
| 322 |
+
var testIter = {
|
| 323 |
+
next: function () {
|
| 324 |
+
return { done: false, value: 1 };
|
| 325 |
+
},
|
| 326 |
+
'return': function () {
|
| 327 |
+
returnCalls += 1;
|
| 328 |
+
return { done: true, value: undefined };
|
| 329 |
+
}
|
| 330 |
+
};
|
| 331 |
+
|
| 332 |
+
var iter = map(testIter, function (x) { return x; });
|
| 333 |
+
iter.next();
|
| 334 |
+
s2t.equal(returnCalls, 0, 'return not called before calling return()');
|
| 335 |
+
iter['return']();
|
| 336 |
+
s2t.equal(returnCalls, 1, 'return called once');
|
| 337 |
+
|
| 338 |
+
s2t.end();
|
| 339 |
+
});
|
| 340 |
+
|
| 341 |
+
st.test('262: return is not forwarded after exhaustion', function (s2t) {
|
| 342 |
+
var returnCalls = 0;
|
| 343 |
+
|
| 344 |
+
var testIter = {
|
| 345 |
+
next: function () {
|
| 346 |
+
return { done: true, value: undefined };
|
| 347 |
+
},
|
| 348 |
+
'return': function () {
|
| 349 |
+
returnCalls += 1;
|
| 350 |
+
throw new EvalError('return should not be called');
|
| 351 |
+
}
|
| 352 |
+
};
|
| 353 |
+
|
| 354 |
+
var iter = map(testIter, function (x) { return x; });
|
| 355 |
+
iter.next();
|
| 356 |
+
iter['return']();
|
| 357 |
+
s2t.equal(returnCalls, 0, 'return not called after exhaustion');
|
| 358 |
+
|
| 359 |
+
s2t.end();
|
| 360 |
+
});
|
| 361 |
+
|
| 362 |
+
st.test('262: iterator already exhausted', function (s2t) {
|
| 363 |
+
var testIter = {
|
| 364 |
+
next: function () {
|
| 365 |
+
return { done: true, value: undefined };
|
| 366 |
+
}
|
| 367 |
+
};
|
| 368 |
+
|
| 369 |
+
var mapperCalls = 0;
|
| 370 |
+
var iter = map(testIter, function (x) {
|
| 371 |
+
mapperCalls += 1;
|
| 372 |
+
return x;
|
| 373 |
+
});
|
| 374 |
+
|
| 375 |
+
var nextResult = iter.next();
|
| 376 |
+
s2t.equal(nextResult.done, true, 'done is true');
|
| 377 |
+
s2t.equal(nextResult.value, undefined, 'value is undefined');
|
| 378 |
+
s2t.equal(mapperCalls, 0, 'mapper not called for exhausted iterator');
|
| 379 |
+
|
| 380 |
+
s2t.end();
|
| 381 |
+
});
|
| 382 |
+
|
| 383 |
+
st.test('262: throws TypeError when generator is running', function (s2t) {
|
| 384 |
+
var reentrantIterator;
|
| 385 |
+
var testIter = {
|
| 386 |
+
next: function () {
|
| 387 |
+
reentrantIterator.next();
|
| 388 |
+
return { done: false, value: 1 };
|
| 389 |
+
}
|
| 390 |
+
};
|
| 391 |
+
|
| 392 |
+
reentrantIterator = map(testIter, function (x) { return x; });
|
| 393 |
+
s2t['throws'](function () { reentrantIterator.next(); }, TypeError, 'throws on reentrant next()');
|
| 394 |
+
|
| 395 |
+
s2t.end();
|
| 396 |
+
});
|
| 397 |
+
|
| 398 |
+
st.test('262: underlying iterator closed when mapper returns abrupt', function (s2t) {
|
| 399 |
+
var returnCalls = 0;
|
| 400 |
+
|
| 401 |
+
var testIter = {
|
| 402 |
+
next: function () {
|
| 403 |
+
return { done: false, value: 1 };
|
| 404 |
+
},
|
| 405 |
+
'return': function () {
|
| 406 |
+
returnCalls += 1;
|
| 407 |
+
return { done: true, value: undefined };
|
| 408 |
+
}
|
| 409 |
+
};
|
| 410 |
+
|
| 411 |
+
var iter = map(testIter, function () {
|
| 412 |
+
throw new EvalError('mapper threw');
|
| 413 |
+
});
|
| 414 |
+
|
| 415 |
+
s2t['throws'](function () { iter.next(); }, EvalError);
|
| 416 |
+
s2t.equal(returnCalls, 1, 'underlying iterator closed on mapper throw');
|
| 417 |
+
|
| 418 |
+
s2t.end();
|
| 419 |
+
});
|
| 420 |
+
|
| 421 |
+
st.end();
|
| 422 |
+
});
|
| 423 |
+
},
|
| 424 |
+
index: function () {
|
| 425 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 426 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 427 |
+
|
| 428 |
+
t.end();
|
| 429 |
+
});
|
| 430 |
+
},
|
| 431 |
+
implementation: function () {
|
| 432 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 433 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 434 |
+
|
| 435 |
+
t.end();
|
| 436 |
+
});
|
| 437 |
+
},
|
| 438 |
+
shimmed: function () {
|
| 439 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 440 |
+
t.equal(typeof Iterator.prototype[fnName], 'function', 'exists and is a function');
|
| 441 |
+
|
| 442 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 443 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 444 |
+
st.end();
|
| 445 |
+
});
|
| 446 |
+
|
| 447 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 448 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 449 |
+
et.end();
|
| 450 |
+
});
|
| 451 |
+
|
| 452 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 453 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 454 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 455 |
+
st.end();
|
| 456 |
+
});
|
| 457 |
+
|
| 458 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 459 |
+
|
| 460 |
+
t.end();
|
| 461 |
+
});
|
| 462 |
+
}
|
| 463 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.reduce.js
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var iterate = require('iterate-iterator');
|
| 13 |
+
|
| 14 |
+
var index = require('../Iterator.prototype.reduce');
|
| 15 |
+
var impl = require('../Iterator.prototype.reduce/implementation');
|
| 16 |
+
|
| 17 |
+
var fnName = 'reduce';
|
| 18 |
+
|
| 19 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 20 |
+
|
| 21 |
+
var testIterator = require('./helpers/testIterator');
|
| 22 |
+
|
| 23 |
+
module.exports = {
|
| 24 |
+
tests: function (reduce, name, t) {
|
| 25 |
+
t['throws'](
|
| 26 |
+
function () { return new reduce(); }, // eslint-disable-line new-cap
|
| 27 |
+
TypeError,
|
| 28 |
+
'`' + name + '` is not a constructor'
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 32 |
+
t['throws'](
|
| 33 |
+
function () { iterate(reduce(nonIterator, function () {})); },
|
| 34 |
+
TypeError,
|
| 35 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
var badNext = { next: nonIterator };
|
| 39 |
+
t['throws'](
|
| 40 |
+
function () { iterate(reduce(badNext, function () {})); },
|
| 41 |
+
TypeError,
|
| 42 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 43 |
+
);
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 47 |
+
t['throws'](
|
| 48 |
+
function () { reduce({ next: function () {} }, nonFunction); },
|
| 49 |
+
TypeError,
|
| 50 |
+
debug(nonFunction) + ' is not a function'
|
| 51 |
+
);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 55 |
+
var arr = [1, 2, 3];
|
| 56 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 57 |
+
|
| 58 |
+
st['throws'](
|
| 59 |
+
function () { return new reduce(iterator()); }, // eslint-disable-line new-cap
|
| 60 |
+
TypeError,
|
| 61 |
+
'`' + name + '` iterator is not a constructor'
|
| 62 |
+
);
|
| 63 |
+
st['throws'](
|
| 64 |
+
function () { return new reduce(iterator(), function () {}); }, // eslint-disable-line new-cap
|
| 65 |
+
TypeError,
|
| 66 |
+
'`' + name + '` iterator is not a constructor'
|
| 67 |
+
);
|
| 68 |
+
|
| 69 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 70 |
+
|
| 71 |
+
var results = [];
|
| 72 |
+
var ret = reduce(
|
| 73 |
+
iterator(),
|
| 74 |
+
function (acc, x, i) {
|
| 75 |
+
|
| 76 |
+
results.push({ acc: acc, value: x, count: i, 'this': this, args: arguments.length });
|
| 77 |
+
return acc + x;
|
| 78 |
+
}
|
| 79 |
+
);
|
| 80 |
+
st.equal(ret, 6, 'returns sum of all numbers');
|
| 81 |
+
st.deepEqual(
|
| 82 |
+
results,
|
| 83 |
+
[
|
| 84 |
+
{ acc: 1, value: 2, count: 1, 'this': undefined, args: 3 },
|
| 85 |
+
{ acc: 3, value: 3, count: 2, 'this': undefined, args: 3 }
|
| 86 |
+
],
|
| 87 |
+
'reduce callback receives the expected values without initialValue'
|
| 88 |
+
);
|
| 89 |
+
|
| 90 |
+
var results2 = [];
|
| 91 |
+
var ret2 = reduce(
|
| 92 |
+
iterator(),
|
| 93 |
+
function (acc, x, i) {
|
| 94 |
+
|
| 95 |
+
results2.push({ acc: acc, value: x, count: i, 'this': this, args: arguments.length });
|
| 96 |
+
return acc + x;
|
| 97 |
+
},
|
| 98 |
+
10
|
| 99 |
+
);
|
| 100 |
+
st.equal(ret2, 16, 'returns sum of all numbers plus initialValue');
|
| 101 |
+
st.deepEqual(
|
| 102 |
+
results2,
|
| 103 |
+
[
|
| 104 |
+
{ acc: 10, value: 1, count: 0, 'this': undefined, args: 3 },
|
| 105 |
+
{ acc: 11, value: 2, count: 1, 'this': undefined, args: 3 },
|
| 106 |
+
{ acc: 13, value: 3, count: 2, 'this': undefined, args: 3 }
|
| 107 |
+
],
|
| 108 |
+
'reduce callback receives the expected values with initialValue'
|
| 109 |
+
);
|
| 110 |
+
|
| 111 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/reducer-args-initial-value', function (s2t) {
|
| 112 |
+
var assertionCount = 0;
|
| 113 |
+
var result = reduce(
|
| 114 |
+
['a', 'b', 'c'][Symbol.iterator](),
|
| 115 |
+
function (memo, value, count) {
|
| 116 |
+
if (value === 'a') {
|
| 117 |
+
s2t.equal(memo, 'start', 'memo is initial value for first call');
|
| 118 |
+
s2t.equal(count, 0);
|
| 119 |
+
} else if (value === 'b') {
|
| 120 |
+
s2t.equal(memo, 'a', 'memo is previous return');
|
| 121 |
+
s2t.equal(count, 1);
|
| 122 |
+
} else if (value === 'c') {
|
| 123 |
+
s2t.equal(memo, 'b', 'memo is previous return');
|
| 124 |
+
s2t.equal(count, 2);
|
| 125 |
+
} else {
|
| 126 |
+
s2t.fail('unexpected value');
|
| 127 |
+
}
|
| 128 |
+
assertionCount += 1;
|
| 129 |
+
return value;
|
| 130 |
+
},
|
| 131 |
+
'start'
|
| 132 |
+
);
|
| 133 |
+
s2t.equal(result, 'c', 'reduce returns last value');
|
| 134 |
+
s2t.equal(assertionCount, 3, 'reducer called three times');
|
| 135 |
+
|
| 136 |
+
s2t.end();
|
| 137 |
+
});
|
| 138 |
+
|
| 139 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/reducer-args-no-initial-value', function (s2t) {
|
| 140 |
+
var assertionCount = 0;
|
| 141 |
+
var result = reduce(
|
| 142 |
+
['a', 'b', 'c'][Symbol.iterator](),
|
| 143 |
+
function (memo, value, count) {
|
| 144 |
+
if (value === 'b') {
|
| 145 |
+
s2t.equal(memo, 'a', 'memo is first value when no initial');
|
| 146 |
+
s2t.equal(count, 1);
|
| 147 |
+
} else if (value === 'c') {
|
| 148 |
+
s2t.equal(memo, 'b', 'memo is previous return');
|
| 149 |
+
s2t.equal(count, 2);
|
| 150 |
+
} else {
|
| 151 |
+
s2t.fail('unexpected value');
|
| 152 |
+
}
|
| 153 |
+
assertionCount += 1;
|
| 154 |
+
return value;
|
| 155 |
+
}
|
| 156 |
+
);
|
| 157 |
+
s2t.equal(result, 'c', 'reduce returns last value');
|
| 158 |
+
s2t.equal(assertionCount, 2, 'reducer called twice');
|
| 159 |
+
|
| 160 |
+
s2t.end();
|
| 161 |
+
});
|
| 162 |
+
|
| 163 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/reducer-this', function (s2t) {
|
| 164 |
+
var expectedThis = (function () { return this; }()); // eslint-disable-line no-invalid-this
|
| 165 |
+
var assertionCount = 0;
|
| 166 |
+
var result = reduce(
|
| 167 |
+
[0, 1][Symbol.iterator](),
|
| 168 |
+
function () {
|
| 169 |
+
s2t.equal(this, expectedThis, 'reducer this is undefined'); // eslint-disable-line no-invalid-this
|
| 170 |
+
assertionCount += 1;
|
| 171 |
+
return 0;
|
| 172 |
+
}
|
| 173 |
+
);
|
| 174 |
+
s2t.equal(result, 0);
|
| 175 |
+
s2t.equal(assertionCount, 1, 'reducer called once');
|
| 176 |
+
|
| 177 |
+
s2t.end();
|
| 178 |
+
});
|
| 179 |
+
|
| 180 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/reducer-throws', function (s2t) {
|
| 181 |
+
var returnCount = 0;
|
| 182 |
+
var testIter = {
|
| 183 |
+
next: function () {
|
| 184 |
+
return { done: false, value: 1 };
|
| 185 |
+
},
|
| 186 |
+
'return': function () {
|
| 187 |
+
returnCount += 1;
|
| 188 |
+
return { done: true };
|
| 189 |
+
}
|
| 190 |
+
};
|
| 191 |
+
|
| 192 |
+
var callbackCount = 0;
|
| 193 |
+
s2t['throws'](
|
| 194 |
+
function () {
|
| 195 |
+
reduce(testIter, function () {
|
| 196 |
+
callbackCount += 1;
|
| 197 |
+
throw new SyntaxError('reducer threw');
|
| 198 |
+
}, 0);
|
| 199 |
+
},
|
| 200 |
+
SyntaxError
|
| 201 |
+
);
|
| 202 |
+
s2t.equal(callbackCount, 1, 'reducer called once');
|
| 203 |
+
s2t.equal(returnCount, 1, 'iterator closed when reducer throws');
|
| 204 |
+
|
| 205 |
+
s2t.end();
|
| 206 |
+
});
|
| 207 |
+
|
| 208 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/iterator-already-exhausted-initial-value', function (s2t) {
|
| 209 |
+
var iter = [][Symbol.iterator]();
|
| 210 |
+
var callbackCount = 0;
|
| 211 |
+
var result = reduce(iter, function () {
|
| 212 |
+
callbackCount += 1;
|
| 213 |
+
return 'called';
|
| 214 |
+
}, 'initial');
|
| 215 |
+
s2t.equal(result, 'initial', 'reduce returns initial value for empty iterator');
|
| 216 |
+
s2t.equal(callbackCount, 0, 'reducer not called');
|
| 217 |
+
|
| 218 |
+
s2t.end();
|
| 219 |
+
});
|
| 220 |
+
|
| 221 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/iterator-already-exhausted-no-initial-value', function (s2t) {
|
| 222 |
+
var iter = [][Symbol.iterator]();
|
| 223 |
+
s2t['throws'](
|
| 224 |
+
function () {
|
| 225 |
+
reduce(iter, function () {});
|
| 226 |
+
},
|
| 227 |
+
TypeError,
|
| 228 |
+
'reduce throws TypeError for empty iterator without initial value'
|
| 229 |
+
);
|
| 230 |
+
|
| 231 |
+
s2t.end();
|
| 232 |
+
});
|
| 233 |
+
|
| 234 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/iterator-yields-once-initial-value', function (s2t) {
|
| 235 |
+
var callbackCount = 0;
|
| 236 |
+
var result = reduce(
|
| 237 |
+
[42][Symbol.iterator](),
|
| 238 |
+
function (memo, value) {
|
| 239 |
+
callbackCount += 1;
|
| 240 |
+
return memo + value;
|
| 241 |
+
},
|
| 242 |
+
10
|
| 243 |
+
);
|
| 244 |
+
s2t.equal(result, 52, 'reduce returns sum');
|
| 245 |
+
s2t.equal(callbackCount, 1, 'reducer called once');
|
| 246 |
+
|
| 247 |
+
s2t.end();
|
| 248 |
+
});
|
| 249 |
+
|
| 250 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/iterator-yields-once-no-initial-value', function (s2t) {
|
| 251 |
+
var callbackCount = 0;
|
| 252 |
+
var result = reduce(
|
| 253 |
+
[42][Symbol.iterator](),
|
| 254 |
+
function () {
|
| 255 |
+
callbackCount += 1;
|
| 256 |
+
return 'called';
|
| 257 |
+
}
|
| 258 |
+
);
|
| 259 |
+
s2t.equal(result, 42, 'reduce returns sole value');
|
| 260 |
+
s2t.equal(callbackCount, 0, 'reducer not called');
|
| 261 |
+
|
| 262 |
+
s2t.end();
|
| 263 |
+
});
|
| 264 |
+
|
| 265 |
+
st.test('test262: test/built-ins/Iterator/prototype/reduce/reducer-memo-can-be-any-type', function (s2t) {
|
| 266 |
+
// test various memo types
|
| 267 |
+
s2t.equal(reduce([1][Symbol.iterator](), function (m) { return m; }, null), null, 'null memo');
|
| 268 |
+
s2t.equal(reduce([1][Symbol.iterator](), function (m) { return m; }, undefined), undefined, 'undefined memo');
|
| 269 |
+
s2t.equal(reduce([1][Symbol.iterator](), function (m) { return m; }, 0), 0, 'number memo');
|
| 270 |
+
s2t.equal(reduce([1][Symbol.iterator](), function (m) { return m; }, ''), '', 'string memo');
|
| 271 |
+
s2t.equal(reduce([1][Symbol.iterator](), function (m) { return m; }, false), false, 'boolean memo');
|
| 272 |
+
var obj = {};
|
| 273 |
+
s2t.equal(reduce([1][Symbol.iterator](), function (m) { return m; }, obj), obj, 'object memo');
|
| 274 |
+
|
| 275 |
+
s2t.end();
|
| 276 |
+
});
|
| 277 |
+
|
| 278 |
+
st.end();
|
| 279 |
+
});
|
| 280 |
+
},
|
| 281 |
+
index: function () {
|
| 282 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 283 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 284 |
+
|
| 285 |
+
t.end();
|
| 286 |
+
});
|
| 287 |
+
},
|
| 288 |
+
implementation: function () {
|
| 289 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 290 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 291 |
+
|
| 292 |
+
t.end();
|
| 293 |
+
});
|
| 294 |
+
},
|
| 295 |
+
shimmed: function () {
|
| 296 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 297 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 298 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 299 |
+
st.end();
|
| 300 |
+
});
|
| 301 |
+
|
| 302 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 303 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 304 |
+
et.end();
|
| 305 |
+
});
|
| 306 |
+
|
| 307 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 308 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 309 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 310 |
+
st.end();
|
| 311 |
+
});
|
| 312 |
+
|
| 313 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 314 |
+
|
| 315 |
+
t.end();
|
| 316 |
+
});
|
| 317 |
+
}
|
| 318 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.some.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var iterate = require('iterate-iterator');
|
| 13 |
+
|
| 14 |
+
var index = require('../Iterator.prototype.some');
|
| 15 |
+
var impl = require('../Iterator.prototype.some/implementation');
|
| 16 |
+
|
| 17 |
+
var fnName = 'some';
|
| 18 |
+
|
| 19 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 20 |
+
|
| 21 |
+
var testIterator = require('./helpers/testIterator');
|
| 22 |
+
|
| 23 |
+
module.exports = {
|
| 24 |
+
tests: function (some, name, t) {
|
| 25 |
+
t['throws'](
|
| 26 |
+
function () { return new some(); }, // eslint-disable-line new-cap
|
| 27 |
+
TypeError,
|
| 28 |
+
'`' + name + '` is not a constructor'
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 32 |
+
t['throws'](
|
| 33 |
+
function () { iterate(some(nonIterator, function () {})); },
|
| 34 |
+
TypeError,
|
| 35 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
var badNext = { next: nonIterator };
|
| 39 |
+
t['throws'](
|
| 40 |
+
function () { iterate(some(badNext, function () {})); },
|
| 41 |
+
TypeError,
|
| 42 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 43 |
+
);
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 47 |
+
t['throws'](
|
| 48 |
+
function () { some({ next: function () {} }, nonFunction); },
|
| 49 |
+
TypeError,
|
| 50 |
+
debug(nonFunction) + ' is not a function'
|
| 51 |
+
);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 55 |
+
var arr = [1, 2, 3];
|
| 56 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 57 |
+
|
| 58 |
+
st['throws'](
|
| 59 |
+
function () { return new some(iterator()); }, // eslint-disable-line new-cap
|
| 60 |
+
TypeError,
|
| 61 |
+
'`' + name + '` iterator is not a constructor'
|
| 62 |
+
);
|
| 63 |
+
st['throws'](
|
| 64 |
+
function () { return new some(iterator(), function () {}); }, // eslint-disable-line new-cap
|
| 65 |
+
TypeError,
|
| 66 |
+
'`' + name + '` iterator is not a constructor'
|
| 67 |
+
);
|
| 68 |
+
|
| 69 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 70 |
+
st.equal(some(iterator(), function () { return false; }), false, 'some for always-false');
|
| 71 |
+
st.equal(some(iterator(), function () { return true; }), true, 'some for always-true');
|
| 72 |
+
st.equal(some(iterator(), function (x, i) { return x === 2 && i === 1; }), true, 'some returns true for matching value/index');
|
| 73 |
+
|
| 74 |
+
st.test('test262: test/built-ins/Iterator/prototype/some/predicate-args', function (s2t) {
|
| 75 |
+
var assertionCount = 0;
|
| 76 |
+
var result = some(
|
| 77 |
+
['a', 'b', 'c'][Symbol.iterator](),
|
| 78 |
+
function (value, count) {
|
| 79 |
+
if (value === 'a') {
|
| 80 |
+
s2t.equal(count, 0);
|
| 81 |
+
} else if (value === 'b') {
|
| 82 |
+
s2t.equal(count, 1);
|
| 83 |
+
} else if (value === 'c') {
|
| 84 |
+
s2t.equal(count, 2);
|
| 85 |
+
} else {
|
| 86 |
+
s2t.fail('unexpected value');
|
| 87 |
+
}
|
| 88 |
+
assertionCount += 1;
|
| 89 |
+
return false;
|
| 90 |
+
}
|
| 91 |
+
);
|
| 92 |
+
s2t.equal(result, false, 'some returns false when none match');
|
| 93 |
+
s2t.equal(assertionCount, 3, 'predicate called three times');
|
| 94 |
+
|
| 95 |
+
s2t.end();
|
| 96 |
+
});
|
| 97 |
+
|
| 98 |
+
st.test('test262: test/built-ins/Iterator/prototype/some/predicate-this', function (s2t) {
|
| 99 |
+
var expectedThis = (function () { return this; }()); // eslint-disable-line no-invalid-this
|
| 100 |
+
var assertionCount = 0;
|
| 101 |
+
var result = some(
|
| 102 |
+
[0][Symbol.iterator](),
|
| 103 |
+
function () {
|
| 104 |
+
s2t.equal(this, expectedThis, 'predicate this is undefined'); // eslint-disable-line no-invalid-this
|
| 105 |
+
assertionCount += 1;
|
| 106 |
+
return true;
|
| 107 |
+
}
|
| 108 |
+
);
|
| 109 |
+
s2t.equal(result, true);
|
| 110 |
+
s2t.equal(assertionCount, 1);
|
| 111 |
+
|
| 112 |
+
s2t.end();
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
st.test('test262: test/built-ins/Iterator/prototype/some/predicate-returns-truthy', function (s2t) {
|
| 116 |
+
var callCount = 0;
|
| 117 |
+
var returnCalled = false;
|
| 118 |
+
var values = [0, 1, 2];
|
| 119 |
+
var idx = 0;
|
| 120 |
+
var iter = {
|
| 121 |
+
next: function () {
|
| 122 |
+
if (idx < values.length) {
|
| 123 |
+
var val = values[idx];
|
| 124 |
+
idx += 1;
|
| 125 |
+
return { done: false, value: val };
|
| 126 |
+
}
|
| 127 |
+
return { done: true, value: undefined };
|
| 128 |
+
},
|
| 129 |
+
'return': function () {
|
| 130 |
+
returnCalled = true;
|
| 131 |
+
return { done: true, value: undefined };
|
| 132 |
+
}
|
| 133 |
+
};
|
| 134 |
+
var result = some(
|
| 135 |
+
iter,
|
| 136 |
+
function () {
|
| 137 |
+
callCount += 1;
|
| 138 |
+
return true;
|
| 139 |
+
}
|
| 140 |
+
);
|
| 141 |
+
s2t.equal(result, true, 'some returns true when predicate returns truthy');
|
| 142 |
+
s2t.equal(callCount, 1, 'predicate called once');
|
| 143 |
+
s2t.equal(returnCalled, true, 'iterator is closed');
|
| 144 |
+
|
| 145 |
+
s2t.end();
|
| 146 |
+
});
|
| 147 |
+
|
| 148 |
+
st.test('test262: test/built-ins/Iterator/prototype/some/predicate-returns-falsey', function (s2t) {
|
| 149 |
+
var result = some(
|
| 150 |
+
[0, 1, 2, 3, 4][Symbol.iterator](),
|
| 151 |
+
function () { return false; }
|
| 152 |
+
);
|
| 153 |
+
s2t.equal(result, false, 'some returns false when predicate always returns falsey');
|
| 154 |
+
|
| 155 |
+
s2t.end();
|
| 156 |
+
});
|
| 157 |
+
|
| 158 |
+
st.test('test262: test/built-ins/Iterator/prototype/some/predicate-returns-falsey-then-truthy', function (s2t) {
|
| 159 |
+
var callCount = 0;
|
| 160 |
+
var returnCalled = false;
|
| 161 |
+
var values = [0, 1, 2, 3, 4];
|
| 162 |
+
var idx = 0;
|
| 163 |
+
var iter = {
|
| 164 |
+
next: function () {
|
| 165 |
+
if (idx < values.length) {
|
| 166 |
+
var val = values[idx];
|
| 167 |
+
idx += 1;
|
| 168 |
+
return { done: false, value: val };
|
| 169 |
+
}
|
| 170 |
+
return { done: true, value: undefined };
|
| 171 |
+
},
|
| 172 |
+
'return': function () {
|
| 173 |
+
returnCalled = true;
|
| 174 |
+
return { done: true, value: undefined };
|
| 175 |
+
}
|
| 176 |
+
};
|
| 177 |
+
var result = some(
|
| 178 |
+
iter,
|
| 179 |
+
function (value) {
|
| 180 |
+
callCount += 1;
|
| 181 |
+
return value >= 3;
|
| 182 |
+
}
|
| 183 |
+
);
|
| 184 |
+
s2t.equal(result, true, 'some returns true when predicate returns truthy');
|
| 185 |
+
s2t.equal(callCount, 4, 'predicate called until truthy returned');
|
| 186 |
+
s2t.equal(returnCalled, true, 'iterator is closed');
|
| 187 |
+
|
| 188 |
+
s2t.end();
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
st.test('test262: test/built-ins/Iterator/prototype/some/predicate-returns-non-boolean', function (s2t) {
|
| 192 |
+
// truthy non-boolean values
|
| 193 |
+
s2t.equal(some([1][Symbol.iterator](), function () { return 1; }), true, 'truthy number');
|
| 194 |
+
s2t.equal(some([1][Symbol.iterator](), function () { return 'yes'; }), true, 'truthy string');
|
| 195 |
+
s2t.equal(some([1][Symbol.iterator](), function () { return {}; }), true, 'truthy object');
|
| 196 |
+
|
| 197 |
+
// falsy non-boolean values
|
| 198 |
+
s2t.equal(some([1][Symbol.iterator](), function () { return 0; }), false, 'falsy number');
|
| 199 |
+
s2t.equal(some([1][Symbol.iterator](), function () { return ''; }), false, 'falsy string');
|
| 200 |
+
s2t.equal(some([1][Symbol.iterator](), function () { return null; }), false, 'null');
|
| 201 |
+
|
| 202 |
+
s2t.end();
|
| 203 |
+
});
|
| 204 |
+
|
| 205 |
+
st.test('test262: test/built-ins/Iterator/prototype/some/predicate-throws', function (s2t) {
|
| 206 |
+
var returnCount = 0;
|
| 207 |
+
var testIter = {
|
| 208 |
+
next: function () {
|
| 209 |
+
return { done: false, value: 1 };
|
| 210 |
+
},
|
| 211 |
+
'return': function () {
|
| 212 |
+
returnCount += 1;
|
| 213 |
+
return { done: true };
|
| 214 |
+
}
|
| 215 |
+
};
|
| 216 |
+
|
| 217 |
+
var callbackCount = 0;
|
| 218 |
+
s2t['throws'](
|
| 219 |
+
function () {
|
| 220 |
+
some(testIter, function () {
|
| 221 |
+
callbackCount += 1;
|
| 222 |
+
throw new SyntaxError('predicate threw');
|
| 223 |
+
});
|
| 224 |
+
},
|
| 225 |
+
SyntaxError
|
| 226 |
+
);
|
| 227 |
+
s2t.equal(callbackCount, 1, 'predicate called once');
|
| 228 |
+
s2t.equal(returnCount, 1, 'iterator closed when predicate throws');
|
| 229 |
+
|
| 230 |
+
s2t.end();
|
| 231 |
+
});
|
| 232 |
+
|
| 233 |
+
st.test('test262: test/built-ins/Iterator/prototype/some/iterator-already-exhausted', function (s2t) {
|
| 234 |
+
var iter = [][Symbol.iterator]();
|
| 235 |
+
var callbackCount = 0;
|
| 236 |
+
var result = some(iter, function () {
|
| 237 |
+
callbackCount += 1;
|
| 238 |
+
return true;
|
| 239 |
+
});
|
| 240 |
+
s2t.equal(result, false, 'some returns false for empty iterator');
|
| 241 |
+
s2t.equal(callbackCount, 0, 'predicate not called');
|
| 242 |
+
|
| 243 |
+
s2t.end();
|
| 244 |
+
});
|
| 245 |
+
|
| 246 |
+
st.end();
|
| 247 |
+
});
|
| 248 |
+
},
|
| 249 |
+
index: function () {
|
| 250 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 251 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 252 |
+
|
| 253 |
+
t.end();
|
| 254 |
+
});
|
| 255 |
+
},
|
| 256 |
+
implementation: function () {
|
| 257 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 258 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 259 |
+
|
| 260 |
+
t.end();
|
| 261 |
+
});
|
| 262 |
+
},
|
| 263 |
+
shimmed: function () {
|
| 264 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 265 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 266 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 267 |
+
st.end();
|
| 268 |
+
});
|
| 269 |
+
|
| 270 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 271 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 272 |
+
et.end();
|
| 273 |
+
});
|
| 274 |
+
|
| 275 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 276 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 277 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 278 |
+
st.end();
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 282 |
+
|
| 283 |
+
t.end();
|
| 284 |
+
});
|
| 285 |
+
}
|
| 286 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.take.js
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 13 |
+
var iterate = require('iterate-iterator');
|
| 14 |
+
|
| 15 |
+
var index = require('../Iterator.prototype.take');
|
| 16 |
+
var impl = require('../Iterator.prototype.take/implementation');
|
| 17 |
+
|
| 18 |
+
var fnName = 'take';
|
| 19 |
+
|
| 20 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 21 |
+
|
| 22 |
+
var testIterator = require('./helpers/testIterator');
|
| 23 |
+
|
| 24 |
+
module.exports = {
|
| 25 |
+
tests: function (take, name, t) {
|
| 26 |
+
t['throws'](
|
| 27 |
+
function () { return new take(); }, // eslint-disable-line new-cap
|
| 28 |
+
TypeError,
|
| 29 |
+
'`' + name + '` itself is not a constructor'
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 33 |
+
t['throws'](
|
| 34 |
+
function () { iterate(take(nonIterator, 1)); },
|
| 35 |
+
TypeError,
|
| 36 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 37 |
+
);
|
| 38 |
+
|
| 39 |
+
if (nonIterator != null && typeof nonIterator !== 'string') {
|
| 40 |
+
var badNext = { next: nonIterator };
|
| 41 |
+
t['throws'](
|
| 42 |
+
function () { iterate(take(badNext, 1)); },
|
| 43 |
+
TypeError,
|
| 44 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 45 |
+
);
|
| 46 |
+
}
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
var arr = [1, 2, 3];
|
| 50 |
+
|
| 51 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 52 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 53 |
+
|
| 54 |
+
st['throws'](
|
| 55 |
+
function () { take(iterator(), -3); },
|
| 56 |
+
RangeError,
|
| 57 |
+
'-3 is not >= 0'
|
| 58 |
+
);
|
| 59 |
+
|
| 60 |
+
st['throws'](
|
| 61 |
+
function () { return new take(iterator()); }, // eslint-disable-line new-cap
|
| 62 |
+
TypeError,
|
| 63 |
+
'`' + name + '` iterator is not a constructor'
|
| 64 |
+
);
|
| 65 |
+
st['throws'](
|
| 66 |
+
function () { return new take(iterator(), 0); }, // eslint-disable-line new-cap
|
| 67 |
+
TypeError,
|
| 68 |
+
'`' + name + '` iterator is not a constructor'
|
| 69 |
+
);
|
| 70 |
+
|
| 71 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 72 |
+
testIterator(take(iterator(), 0), [], st, 'take 0');
|
| 73 |
+
testIterator(take(iterator(), 1), [1], st, 'take 1');
|
| 74 |
+
testIterator(take(iterator(), 2), [1, 2], st, 'take 2');
|
| 75 |
+
testIterator(take(iterator(), 3), [1, 2, 3], st, 'take 3');
|
| 76 |
+
testIterator(take(iterator(), Infinity), [1, 2, 3], st, 'take ∞');
|
| 77 |
+
|
| 78 |
+
st.test('262: limit-tonumber', function (s2t) {
|
| 79 |
+
// ToNumber coercion
|
| 80 |
+
testIterator(take(iterator(), '2'), [1, 2], s2t, 'string "2" coerced to 2');
|
| 81 |
+
testIterator(take(iterator(), 2.9), [1, 2], s2t, '2.9 truncated to 2');
|
| 82 |
+
testIterator(take(iterator(), { valueOf: function () { return 2; } }), [1, 2], s2t, 'object with valueOf');
|
| 83 |
+
testIterator(take(iterator(), true), [1], s2t, 'true coerced to 1');
|
| 84 |
+
testIterator(take(iterator(), null), [], s2t, 'null coerced to 0');
|
| 85 |
+
|
| 86 |
+
s2t.end();
|
| 87 |
+
});
|
| 88 |
+
|
| 89 |
+
st.test('262: limit-tonumber-throws', function (s2t) {
|
| 90 |
+
s2t['throws'](
|
| 91 |
+
function () { take(iterator(), { valueOf: function () { throw new EvalError('valueOf threw'); } }); },
|
| 92 |
+
EvalError,
|
| 93 |
+
'throws when valueOf throws'
|
| 94 |
+
);
|
| 95 |
+
|
| 96 |
+
s2t['throws'](
|
| 97 |
+
function () { take(iterator(), Symbol('test')); },
|
| 98 |
+
TypeError,
|
| 99 |
+
'throws when limit is a Symbol'
|
| 100 |
+
);
|
| 101 |
+
|
| 102 |
+
s2t.end();
|
| 103 |
+
});
|
| 104 |
+
|
| 105 |
+
st.test('262: limit-rangeerror', function (s2t) {
|
| 106 |
+
s2t['throws'](function () { take(iterator(), -1); }, RangeError, '-1 throws RangeError');
|
| 107 |
+
s2t['throws'](function () { take(iterator(), -Infinity); }, RangeError, '-Infinity throws RangeError');
|
| 108 |
+
s2t['throws'](function () { take(iterator(), NaN); }, RangeError, 'NaN throws RangeError');
|
| 109 |
+
|
| 110 |
+
s2t.end();
|
| 111 |
+
});
|
| 112 |
+
|
| 113 |
+
st.test('262: result is iterator', function (s2t) {
|
| 114 |
+
var iter = take(iterator(), 2);
|
| 115 |
+
s2t.equal(typeof iter.next, 'function', 'has next method');
|
| 116 |
+
s2t.equal(typeof iter[Symbol.iterator], 'function', 'has Symbol.iterator method');
|
| 117 |
+
s2t.equal(iter[Symbol.iterator](), iter, 'Symbol.iterator returns itself');
|
| 118 |
+
|
| 119 |
+
s2t.end();
|
| 120 |
+
});
|
| 121 |
+
|
| 122 |
+
st.test('262: get next method only once', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 123 |
+
var nextGets = 0;
|
| 124 |
+
var testIter = {};
|
| 125 |
+
Object.defineProperty(testIter, 'next', {
|
| 126 |
+
get: function () {
|
| 127 |
+
nextGets += 1;
|
| 128 |
+
return function () {
|
| 129 |
+
return { done: true, value: undefined };
|
| 130 |
+
};
|
| 131 |
+
}
|
| 132 |
+
});
|
| 133 |
+
|
| 134 |
+
var iter = take(testIter, 2);
|
| 135 |
+
s2t.equal(nextGets, 1, 'next retrieved once on creation');
|
| 136 |
+
iter.next();
|
| 137 |
+
s2t.equal(nextGets, 1, 'next not retrieved again');
|
| 138 |
+
|
| 139 |
+
s2t.end();
|
| 140 |
+
});
|
| 141 |
+
|
| 142 |
+
st.test('262: get next method throws', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 143 |
+
var testIter = {};
|
| 144 |
+
Object.defineProperty(testIter, 'next', {
|
| 145 |
+
get: function () {
|
| 146 |
+
throw new EvalError('next getter threw');
|
| 147 |
+
}
|
| 148 |
+
});
|
| 149 |
+
|
| 150 |
+
s2t['throws'](
|
| 151 |
+
function () { take(testIter, 2); },
|
| 152 |
+
EvalError,
|
| 153 |
+
'throws when getting next throws'
|
| 154 |
+
);
|
| 155 |
+
|
| 156 |
+
s2t.end();
|
| 157 |
+
});
|
| 158 |
+
|
| 159 |
+
st.test('262: next method returns non-object throws', function (s2t) {
|
| 160 |
+
var badIterator = {
|
| 161 |
+
next: function () {
|
| 162 |
+
return null;
|
| 163 |
+
}
|
| 164 |
+
};
|
| 165 |
+
|
| 166 |
+
var iter = take(badIterator, 2);
|
| 167 |
+
s2t['throws'](function () { iter.next(); }, TypeError, 'throws when next returns null');
|
| 168 |
+
|
| 169 |
+
s2t.end();
|
| 170 |
+
});
|
| 171 |
+
|
| 172 |
+
st.test('262: next method returns throwing done', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 173 |
+
var throwingIterator = {
|
| 174 |
+
next: function () {
|
| 175 |
+
var result = { value: 1 };
|
| 176 |
+
Object.defineProperty(result, 'done', {
|
| 177 |
+
get: function () {
|
| 178 |
+
throw new EvalError('done getter threw');
|
| 179 |
+
}
|
| 180 |
+
});
|
| 181 |
+
return result;
|
| 182 |
+
}
|
| 183 |
+
};
|
| 184 |
+
|
| 185 |
+
var iter = take(throwingIterator, 2);
|
| 186 |
+
s2t['throws'](function () { iter.next(); }, EvalError, 'throws when done getter throws');
|
| 187 |
+
|
| 188 |
+
s2t.end();
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
st.test('262: next method returns throwing value', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 192 |
+
var throwingIterator = {
|
| 193 |
+
next: function () {
|
| 194 |
+
var result = { done: false };
|
| 195 |
+
Object.defineProperty(result, 'value', {
|
| 196 |
+
get: function () {
|
| 197 |
+
throw new EvalError('value getter threw');
|
| 198 |
+
}
|
| 199 |
+
});
|
| 200 |
+
return result;
|
| 201 |
+
}
|
| 202 |
+
};
|
| 203 |
+
|
| 204 |
+
var iter = take(throwingIterator, 2);
|
| 205 |
+
s2t['throws'](function () { iter.next(); }, EvalError, 'throws when value getter throws');
|
| 206 |
+
|
| 207 |
+
s2t.end();
|
| 208 |
+
});
|
| 209 |
+
|
| 210 |
+
st.test('262: next method throws', function (s2t) {
|
| 211 |
+
var throwingIterator = {
|
| 212 |
+
next: function () {
|
| 213 |
+
throw new EvalError('next threw');
|
| 214 |
+
}
|
| 215 |
+
};
|
| 216 |
+
|
| 217 |
+
var iter = take(throwingIterator, 2);
|
| 218 |
+
s2t['throws'](function () { iter.next(); }, EvalError, 'throws error from next');
|
| 219 |
+
|
| 220 |
+
s2t.end();
|
| 221 |
+
});
|
| 222 |
+
|
| 223 |
+
st.test('262: return is forwarded', function (s2t) {
|
| 224 |
+
var returnCalls = 0;
|
| 225 |
+
|
| 226 |
+
var testIter = {
|
| 227 |
+
next: function () {
|
| 228 |
+
return { done: false, value: 1 };
|
| 229 |
+
},
|
| 230 |
+
'return': function () {
|
| 231 |
+
returnCalls += 1;
|
| 232 |
+
return { done: true, value: undefined };
|
| 233 |
+
}
|
| 234 |
+
};
|
| 235 |
+
|
| 236 |
+
var iter = take(testIter, 5);
|
| 237 |
+
iter.next();
|
| 238 |
+
s2t.equal(returnCalls, 0, 'return not called before calling return()');
|
| 239 |
+
iter['return']();
|
| 240 |
+
s2t.equal(returnCalls, 1, 'return called once');
|
| 241 |
+
|
| 242 |
+
s2t.end();
|
| 243 |
+
});
|
| 244 |
+
|
| 245 |
+
st.test('262: return is not forwarded after exhaustion', function (s2t) {
|
| 246 |
+
var returnCalls = 0;
|
| 247 |
+
|
| 248 |
+
var testIter = {
|
| 249 |
+
next: function () {
|
| 250 |
+
return { done: false, value: 1 };
|
| 251 |
+
},
|
| 252 |
+
'return': function () {
|
| 253 |
+
returnCalls += 1;
|
| 254 |
+
return { done: true, value: undefined };
|
| 255 |
+
}
|
| 256 |
+
};
|
| 257 |
+
|
| 258 |
+
var iter = take(testIter, 1);
|
| 259 |
+
iter.next(); // takes the one value, returnCalls still 0
|
| 260 |
+
iter.next(); // exhausted, calls return on underlying -> returnCalls = 1
|
| 261 |
+
s2t.equal(returnCalls, 1, 'return called once on exhaustion');
|
| 262 |
+
|
| 263 |
+
// After exhaustion, calling return() should NOT forward again
|
| 264 |
+
iter['return']();
|
| 265 |
+
s2t.equal(returnCalls, 1, 'return not called again after already exhausted');
|
| 266 |
+
|
| 267 |
+
s2t.end();
|
| 268 |
+
});
|
| 269 |
+
|
| 270 |
+
// Note: "exhaustion calls return" test removed as take's exhaustion behavior
|
| 271 |
+
// depends on implementation details and spec interpretation
|
| 272 |
+
|
| 273 |
+
st.test('262: get return method throws', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 274 |
+
var badIterator = {
|
| 275 |
+
next: function () {
|
| 276 |
+
return { done: false, value: 1 };
|
| 277 |
+
}
|
| 278 |
+
};
|
| 279 |
+
Object.defineProperty(badIterator, 'return', {
|
| 280 |
+
get: function () {
|
| 281 |
+
throw new SyntaxError('return getter threw');
|
| 282 |
+
}
|
| 283 |
+
});
|
| 284 |
+
|
| 285 |
+
var iter = take(badIterator, 5);
|
| 286 |
+
iter.next();
|
| 287 |
+
|
| 288 |
+
s2t['throws'](function () { iter['return'](); }, SyntaxError, 'throws error from return getter');
|
| 289 |
+
|
| 290 |
+
s2t.end();
|
| 291 |
+
});
|
| 292 |
+
|
| 293 |
+
st.test('262: throws TypeError when generator is running', function (s2t) {
|
| 294 |
+
var reentrantIterator;
|
| 295 |
+
var testIter = {
|
| 296 |
+
next: function () {
|
| 297 |
+
reentrantIterator.next();
|
| 298 |
+
return { done: false, value: 1 };
|
| 299 |
+
}
|
| 300 |
+
};
|
| 301 |
+
|
| 302 |
+
reentrantIterator = take(testIter, 5);
|
| 303 |
+
s2t['throws'](function () { reentrantIterator.next(); }, TypeError, 'throws on reentrant next()');
|
| 304 |
+
|
| 305 |
+
s2t.end();
|
| 306 |
+
});
|
| 307 |
+
|
| 308 |
+
st.test('262: limit-greater-than-or-equal-to-total', function (s2t) {
|
| 309 |
+
// When limit >= total items, should return all items
|
| 310 |
+
testIterator(take(iterator(), 5), [1, 2, 3], s2t, 'take 5 from 3-item iterator');
|
| 311 |
+
testIterator(take(iterator(), 3), [1, 2, 3], s2t, 'take exactly 3 from 3-item iterator');
|
| 312 |
+
|
| 313 |
+
s2t.end();
|
| 314 |
+
});
|
| 315 |
+
|
| 316 |
+
st.test('262: limit-less-than-total', function (s2t) {
|
| 317 |
+
// When limit < total items, should stop early
|
| 318 |
+
testIterator(take(iterator(), 2), [1, 2], s2t, 'take 2 from 3-item iterator');
|
| 319 |
+
testIterator(take(iterator(), 1), [1], s2t, 'take 1 from 3-item iterator');
|
| 320 |
+
|
| 321 |
+
s2t.end();
|
| 322 |
+
});
|
| 323 |
+
|
| 324 |
+
st.end();
|
| 325 |
+
});
|
| 326 |
+
},
|
| 327 |
+
index: function () {
|
| 328 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 329 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 330 |
+
|
| 331 |
+
t.end();
|
| 332 |
+
});
|
| 333 |
+
},
|
| 334 |
+
implementation: function () {
|
| 335 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 336 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 337 |
+
|
| 338 |
+
t.end();
|
| 339 |
+
});
|
| 340 |
+
},
|
| 341 |
+
shimmed: function () {
|
| 342 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 343 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 344 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 345 |
+
st.end();
|
| 346 |
+
});
|
| 347 |
+
|
| 348 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 349 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 350 |
+
et.end();
|
| 351 |
+
});
|
| 352 |
+
|
| 353 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 354 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 355 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 356 |
+
st.end();
|
| 357 |
+
});
|
| 358 |
+
|
| 359 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 360 |
+
|
| 361 |
+
t.end();
|
| 362 |
+
});
|
| 363 |
+
}
|
| 364 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.prototype.toArray.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var debug = require('object-inspect');
|
| 10 |
+
var v = require('es-value-fixtures');
|
| 11 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 12 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 13 |
+
var iterate = require('iterate-iterator');
|
| 14 |
+
|
| 15 |
+
var index = require('../Iterator.prototype.toArray');
|
| 16 |
+
var impl = require('../Iterator.prototype.toArray/implementation');
|
| 17 |
+
|
| 18 |
+
var fnName = 'toArray';
|
| 19 |
+
|
| 20 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 21 |
+
|
| 22 |
+
var testIterator = require('./helpers/testIterator');
|
| 23 |
+
|
| 24 |
+
module.exports = {
|
| 25 |
+
tests: function (toArray, name, t) {
|
| 26 |
+
t['throws'](
|
| 27 |
+
function () { return new toArray(); }, // eslint-disable-line new-cap
|
| 28 |
+
TypeError,
|
| 29 |
+
'`' + name + '` is not a constructor'
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 33 |
+
t['throws'](
|
| 34 |
+
function () { iterate(toArray(nonIterator)); },
|
| 35 |
+
TypeError,
|
| 36 |
+
debug(nonIterator) + ' is not an Object with a callable `next` method'
|
| 37 |
+
);
|
| 38 |
+
|
| 39 |
+
var badNext = { next: nonIterator };
|
| 40 |
+
t['throws'](
|
| 41 |
+
function () { iterate(toArray(badNext)); },
|
| 42 |
+
TypeError,
|
| 43 |
+
debug(badNext) + ' is not an Object with a callable `next` method'
|
| 44 |
+
);
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 48 |
+
var arr = [1, 2, 3];
|
| 49 |
+
var iterator = callBind(arr[Symbol.iterator], arr);
|
| 50 |
+
|
| 51 |
+
st['throws'](
|
| 52 |
+
function () { return new toArray(iterator()); }, // eslint-disable-line new-cap
|
| 53 |
+
TypeError,
|
| 54 |
+
'`' + name + '` iterator is not a constructor'
|
| 55 |
+
);
|
| 56 |
+
|
| 57 |
+
testIterator(iterator(), [1, 2, 3], st, 'original');
|
| 58 |
+
|
| 59 |
+
st.deepEqual(toArray(iterator()), [1, 2, 3], 'toArray');
|
| 60 |
+
|
| 61 |
+
st.test('262: iterator-already-exhausted', function (s2t) {
|
| 62 |
+
var exhaustedIter = {
|
| 63 |
+
next: function () {
|
| 64 |
+
return { done: true, value: undefined };
|
| 65 |
+
}
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
var result = toArray(exhaustedIter);
|
| 69 |
+
s2t.ok(Array.isArray(result), 'result is an array');
|
| 70 |
+
s2t.deepEqual(result, [], 'empty array for exhausted iterator');
|
| 71 |
+
|
| 72 |
+
s2t.end();
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
st.test('262: get-next-method-only-once', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 76 |
+
var nextGets = 0;
|
| 77 |
+
var callCount = 0;
|
| 78 |
+
var testIter = {};
|
| 79 |
+
Object.defineProperty(testIter, 'next', {
|
| 80 |
+
get: function () {
|
| 81 |
+
nextGets += 1;
|
| 82 |
+
return function () {
|
| 83 |
+
callCount += 1;
|
| 84 |
+
if (callCount <= 2) {
|
| 85 |
+
return { done: false, value: callCount };
|
| 86 |
+
}
|
| 87 |
+
return { done: true, value: undefined };
|
| 88 |
+
};
|
| 89 |
+
}
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
var result = toArray(testIter);
|
| 93 |
+
s2t.equal(nextGets, 1, 'next retrieved once');
|
| 94 |
+
s2t.deepEqual(result, [1, 2], 'result is correct');
|
| 95 |
+
|
| 96 |
+
s2t.end();
|
| 97 |
+
});
|
| 98 |
+
|
| 99 |
+
st.test('262: get-next-method-throws', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 100 |
+
var testIter = {};
|
| 101 |
+
Object.defineProperty(testIter, 'next', {
|
| 102 |
+
get: function () {
|
| 103 |
+
throw new EvalError('next getter threw');
|
| 104 |
+
}
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
s2t['throws'](
|
| 108 |
+
function () { toArray(testIter); },
|
| 109 |
+
EvalError,
|
| 110 |
+
'throws when getting next throws'
|
| 111 |
+
);
|
| 112 |
+
|
| 113 |
+
s2t.end();
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
st.test('262: next-method-returns-non-object', function (s2t) {
|
| 117 |
+
var badIterator = {
|
| 118 |
+
next: function () {
|
| 119 |
+
return null;
|
| 120 |
+
}
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
s2t['throws'](
|
| 124 |
+
function () { toArray(badIterator); },
|
| 125 |
+
TypeError,
|
| 126 |
+
'throws when next returns null'
|
| 127 |
+
);
|
| 128 |
+
|
| 129 |
+
var badIterator2 = {
|
| 130 |
+
next: function () {
|
| 131 |
+
return 42;
|
| 132 |
+
}
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
s2t['throws'](
|
| 136 |
+
function () { toArray(badIterator2); },
|
| 137 |
+
TypeError,
|
| 138 |
+
'throws when next returns a number'
|
| 139 |
+
);
|
| 140 |
+
|
| 141 |
+
s2t.end();
|
| 142 |
+
});
|
| 143 |
+
|
| 144 |
+
st.test('262: next-method-returns-throwing-done', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 145 |
+
var throwingIterator = {
|
| 146 |
+
next: function () {
|
| 147 |
+
var result = { value: 1 };
|
| 148 |
+
Object.defineProperty(result, 'done', {
|
| 149 |
+
get: function () {
|
| 150 |
+
throw new EvalError('done getter threw');
|
| 151 |
+
}
|
| 152 |
+
});
|
| 153 |
+
return result;
|
| 154 |
+
}
|
| 155 |
+
};
|
| 156 |
+
|
| 157 |
+
s2t['throws'](
|
| 158 |
+
function () { toArray(throwingIterator); },
|
| 159 |
+
EvalError,
|
| 160 |
+
'throws when done getter throws'
|
| 161 |
+
);
|
| 162 |
+
|
| 163 |
+
s2t.end();
|
| 164 |
+
});
|
| 165 |
+
|
| 166 |
+
st.test('262: next-method-returns-throwing-value', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 167 |
+
var throwingIterator = {
|
| 168 |
+
next: function () {
|
| 169 |
+
var result = { done: false };
|
| 170 |
+
Object.defineProperty(result, 'value', {
|
| 171 |
+
get: function () {
|
| 172 |
+
throw new EvalError('value getter threw');
|
| 173 |
+
}
|
| 174 |
+
});
|
| 175 |
+
return result;
|
| 176 |
+
}
|
| 177 |
+
};
|
| 178 |
+
|
| 179 |
+
s2t['throws'](
|
| 180 |
+
function () { toArray(throwingIterator); },
|
| 181 |
+
EvalError,
|
| 182 |
+
'throws when value getter throws'
|
| 183 |
+
);
|
| 184 |
+
|
| 185 |
+
s2t.end();
|
| 186 |
+
});
|
| 187 |
+
|
| 188 |
+
st.test('262: next-method-returns-throwing-value-done', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 189 |
+
// Value property should not be accessed after done: true
|
| 190 |
+
var valueAccessed = false;
|
| 191 |
+
var doneIterator = {
|
| 192 |
+
next: function () {
|
| 193 |
+
var result = { done: true };
|
| 194 |
+
Object.defineProperty(result, 'value', {
|
| 195 |
+
get: function () {
|
| 196 |
+
valueAccessed = true;
|
| 197 |
+
throw new EvalError('value getter threw');
|
| 198 |
+
}
|
| 199 |
+
});
|
| 200 |
+
return result;
|
| 201 |
+
}
|
| 202 |
+
};
|
| 203 |
+
|
| 204 |
+
var result = toArray(doneIterator);
|
| 205 |
+
s2t.deepEqual(result, [], 'toArray returns empty array');
|
| 206 |
+
s2t.equal(valueAccessed, false, 'value not accessed when done is true');
|
| 207 |
+
|
| 208 |
+
s2t.end();
|
| 209 |
+
});
|
| 210 |
+
|
| 211 |
+
st.test('262: next-method-throws', function (s2t) {
|
| 212 |
+
var throwingIterator = {
|
| 213 |
+
next: function () {
|
| 214 |
+
throw new EvalError('next threw');
|
| 215 |
+
}
|
| 216 |
+
};
|
| 217 |
+
|
| 218 |
+
s2t['throws'](
|
| 219 |
+
function () { toArray(throwingIterator); },
|
| 220 |
+
EvalError,
|
| 221 |
+
'throws error from next'
|
| 222 |
+
);
|
| 223 |
+
|
| 224 |
+
s2t.end();
|
| 225 |
+
});
|
| 226 |
+
|
| 227 |
+
st.test('262: this-plain-iterator', function (s2t) {
|
| 228 |
+
// toArray works with plain iterator objects not inheriting from Iterator.prototype
|
| 229 |
+
var callCount = 0;
|
| 230 |
+
var plainIterator = {
|
| 231 |
+
next: function () {
|
| 232 |
+
callCount += 1;
|
| 233 |
+
if (callCount <= 3) {
|
| 234 |
+
return { done: false, value: callCount };
|
| 235 |
+
}
|
| 236 |
+
return { done: true, value: undefined };
|
| 237 |
+
}
|
| 238 |
+
};
|
| 239 |
+
|
| 240 |
+
var result = toArray(plainIterator);
|
| 241 |
+
s2t.deepEqual(result, [1, 2, 3], 'toArray works with plain iterator');
|
| 242 |
+
|
| 243 |
+
s2t.end();
|
| 244 |
+
});
|
| 245 |
+
|
| 246 |
+
st.end();
|
| 247 |
+
});
|
| 248 |
+
},
|
| 249 |
+
index: function () {
|
| 250 |
+
test('Iterator.prototype.' + fnName + ': index', function (t) {
|
| 251 |
+
module.exports.tests(index, 'Iterator.prototype.' + fnName, t);
|
| 252 |
+
|
| 253 |
+
t.end();
|
| 254 |
+
});
|
| 255 |
+
},
|
| 256 |
+
implementation: function () {
|
| 257 |
+
test('Iterator.prototype.' + fnName + ': implementation', function (t) {
|
| 258 |
+
module.exports.tests(callBind(impl), 'Iterator.prototype.' + fnName, t);
|
| 259 |
+
|
| 260 |
+
t.end();
|
| 261 |
+
});
|
| 262 |
+
},
|
| 263 |
+
shimmed: function () {
|
| 264 |
+
test('Iterator.prototype.' + fnName + ': shimmed', function (t) {
|
| 265 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 266 |
+
st.equal(Iterator.prototype[fnName].name, fnName, 'Iterator#' + fnName + ' has name "' + fnName + '"');
|
| 267 |
+
st.end();
|
| 268 |
+
});
|
| 269 |
+
|
| 270 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 271 |
+
et.equal(false, isEnumerable.call(Iterator.prototype, fnName), 'Iterator#' + fnName + ' is not enumerable');
|
| 272 |
+
et.end();
|
| 273 |
+
});
|
| 274 |
+
|
| 275 |
+
t.test('bad string/this value', { skip: !hasStrictMode }, function (st) {
|
| 276 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
| 277 |
+
st['throws'](function () { return Iterator.prototype[fnName].call(null, 'a'); }, TypeError, 'null is not an object');
|
| 278 |
+
st.end();
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
module.exports.tests(callBind(Iterator.prototype[fnName]), 'Iterator.prototype.' + fnName, t);
|
| 282 |
+
|
| 283 |
+
t.end();
|
| 284 |
+
});
|
| 285 |
+
}
|
| 286 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.zip.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var forEach = require('for-each');
|
| 8 |
+
var debug = require('object-inspect');
|
| 9 |
+
var v = require('es-value-fixtures');
|
| 10 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 11 |
+
var mockProperty = require('mock-property');
|
| 12 |
+
|
| 13 |
+
var index = require('../Iterator.zip');
|
| 14 |
+
var impl = require('../Iterator.zip/implementation');
|
| 15 |
+
var from = require('../Iterator.from/polyfill')();
|
| 16 |
+
|
| 17 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 18 |
+
|
| 19 |
+
var testIterator = require('./helpers/testIterator');
|
| 20 |
+
|
| 21 |
+
module.exports = {
|
| 22 |
+
tests: function (zip, name, t) {
|
| 23 |
+
t['throws'](
|
| 24 |
+
function () { return new zip(); }, // eslint-disable-line new-cap
|
| 25 |
+
TypeError,
|
| 26 |
+
'`' + name + '` itself is not a constructor'
|
| 27 |
+
);
|
| 28 |
+
t['throws'](
|
| 29 |
+
function () { return new zip({}); }, // eslint-disable-line new-cap
|
| 30 |
+
TypeError,
|
| 31 |
+
'`' + name + '` itself is not a constructor, with an argument'
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
forEach(v.primitives.concat(v.objects), function (nonIterator) {
|
| 35 |
+
t['throws'](
|
| 36 |
+
function () { zip(nonIterator, []); },
|
| 37 |
+
TypeError,
|
| 38 |
+
debug(nonIterator) + ' is not an iterable Object'
|
| 39 |
+
);
|
| 40 |
+
});
|
| 41 |
+
|
| 42 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 43 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 44 |
+
if (nonFunction != null) {
|
| 45 |
+
var badIterable = {};
|
| 46 |
+
badIterable[Symbol.iterator] = nonFunction;
|
| 47 |
+
st['throws'](
|
| 48 |
+
function () { zip([[], badIterable, []]).next(); },
|
| 49 |
+
TypeError,
|
| 50 |
+
debug(badIterable) + ' is not a function'
|
| 51 |
+
);
|
| 52 |
+
}
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
forEach(v.strings, function (string) {
|
| 56 |
+
st['throws'](
|
| 57 |
+
function () { zip([string]); },
|
| 58 |
+
TypeError,
|
| 59 |
+
'non-objects are not considered iterable'
|
| 60 |
+
);
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
var arrayIt = zip([[1, 2, 3]]);
|
| 64 |
+
st.equal(typeof arrayIt.next, 'function', 'has a `next` function');
|
| 65 |
+
|
| 66 |
+
st.test('real iterators', { skip: !hasSymbols }, function (s2t) {
|
| 67 |
+
var iter = [1, 2][Symbol.iterator]();
|
| 68 |
+
testIterator(zip([iter, [3, 4]]), [[1, 3], [2, 4]], s2t, 'array iterator + array yields combined results');
|
| 69 |
+
|
| 70 |
+
s2t.end();
|
| 71 |
+
});
|
| 72 |
+
|
| 73 |
+
st.test('observability in a replaced String iterator', function (s2t) {
|
| 74 |
+
var originalStringIterator = String.prototype[Symbol.iterator];
|
| 75 |
+
var observedType;
|
| 76 |
+
s2t.teardown(mockProperty(String.prototype, Symbol.iterator, {
|
| 77 |
+
get: function () {
|
| 78 |
+
'use strict'; // eslint-disable-line strict, lines-around-directive
|
| 79 |
+
|
| 80 |
+
observedType = typeof this;
|
| 81 |
+
return originalStringIterator;
|
| 82 |
+
}
|
| 83 |
+
}));
|
| 84 |
+
|
| 85 |
+
zip([from('')]);
|
| 86 |
+
s2t.equal(observedType, 'string', 'string primitive -> primitive receiver in Symbol.iterator getter');
|
| 87 |
+
zip([from(Object(''))]);
|
| 88 |
+
s2t.equal(observedType, 'object', 'boxed string -> boxed string in Symbol.iterator getter');
|
| 89 |
+
|
| 90 |
+
s2t.end();
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
st.test('262: mode option validation', function (s2t) {
|
| 94 |
+
// valid modes should not throw
|
| 95 |
+
s2t.doesNotThrow(function () { zip([[1], [2]]); }, 'undefined mode is valid');
|
| 96 |
+
s2t.doesNotThrow(function () { zip([[1], [2]], { mode: undefined }); }, 'explicit undefined mode is valid');
|
| 97 |
+
s2t.doesNotThrow(function () { zip([[1], [2]], { mode: 'shortest' }); }, '"shortest" mode is valid');
|
| 98 |
+
s2t.doesNotThrow(function () { zip([[1], [2]], { mode: 'longest' }); }, '"longest" mode is valid');
|
| 99 |
+
s2t.doesNotThrow(function () { zip([[1], [2]], { mode: 'strict' }); }, '"strict" mode is valid');
|
| 100 |
+
|
| 101 |
+
// invalid modes should throw TypeError
|
| 102 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: null }); }, TypeError, 'null mode throws TypeError');
|
| 103 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: false }); }, TypeError, 'false mode throws TypeError');
|
| 104 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: '' }); }, TypeError, 'empty string mode throws TypeError');
|
| 105 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: 'short' }); }, TypeError, '"short" mode throws TypeError');
|
| 106 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: 'long' }); }, TypeError, '"long" mode throws TypeError');
|
| 107 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: 'loose' }); }, TypeError, '"loose" mode throws TypeError');
|
| 108 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: 0 }); }, TypeError, '0 mode throws TypeError');
|
| 109 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: {} }); }, TypeError, 'object mode throws TypeError');
|
| 110 |
+
|
| 111 |
+
// String wrapper should not be coerced
|
| 112 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: Object('shortest') }); }, TypeError, 'String wrapper mode throws TypeError');
|
| 113 |
+
|
| 114 |
+
// objects with toString/valueOf should not be coerced
|
| 115 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: { toString: function () { return 'shortest'; } } }); }, TypeError, 'object with toString throws TypeError');
|
| 116 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: { valueOf: function () { return 'shortest'; } } }); }, TypeError, 'object with valueOf throws TypeError');
|
| 117 |
+
|
| 118 |
+
s2t.end();
|
| 119 |
+
});
|
| 120 |
+
|
| 121 |
+
st.test('262: basic shortest mode', function (s2t) {
|
| 122 |
+
// shortest mode (default) stops at minimum length
|
| 123 |
+
testIterator(zip([[1, 2, 3], [4, 5]]), [[1, 4], [2, 5]], s2t, 'shortest mode stops at shorter iterator');
|
| 124 |
+
testIterator(zip([[1, 2], [3, 4, 5]]), [[1, 3], [2, 4]], s2t, 'shortest mode stops at shorter first iterator');
|
| 125 |
+
testIterator(zip([[1], [2], [3]]), [[1, 2, 3]], s2t, 'three iterators of length 1');
|
| 126 |
+
testIterator(zip([[], [1, 2, 3]]), [], s2t, 'empty first iterator yields nothing');
|
| 127 |
+
testIterator(zip([[1, 2, 3], []]), [], s2t, 'empty second iterator yields nothing');
|
| 128 |
+
|
| 129 |
+
// explicit shortest mode
|
| 130 |
+
testIterator(zip([[1, 2, 3], [4, 5]], { mode: 'shortest' }), [[1, 4], [2, 5]], s2t, 'explicit shortest mode');
|
| 131 |
+
|
| 132 |
+
s2t.end();
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
+
st.test('262: basic longest mode', function (s2t) {
|
| 136 |
+
// longest mode continues with undefined padding by default
|
| 137 |
+
testIterator(zip([[1, 2, 3], [4, 5]], { mode: 'longest' }), [[1, 4], [2, 5], [3, undefined]], s2t, 'longest mode pads with undefined');
|
| 138 |
+
testIterator(zip([[1, 2], [3, 4, 5]], { mode: 'longest' }), [[1, 3], [2, 4], [undefined, 5]], s2t, 'longest mode pads first iterator');
|
| 139 |
+
testIterator(zip([[1], [2, 3], [4, 5, 6]], { mode: 'longest' }), [[1, 2, 4], [undefined, 3, 5], [undefined, undefined, 6]], s2t, 'longest mode with three iterators');
|
| 140 |
+
|
| 141 |
+
s2t.end();
|
| 142 |
+
});
|
| 143 |
+
|
| 144 |
+
st.test('262: basic strict mode', function (s2t) {
|
| 145 |
+
// strict mode succeeds when lengths match
|
| 146 |
+
testIterator(zip([[1, 2], [3, 4]], { mode: 'strict' }), [[1, 3], [2, 4]], s2t, 'strict mode succeeds with equal lengths');
|
| 147 |
+
testIterator(zip([[1], [2], [3]], { mode: 'strict' }), [[1, 2, 3]], s2t, 'strict mode with three iterators of length 1');
|
| 148 |
+
|
| 149 |
+
// strict mode throws when lengths differ
|
| 150 |
+
var strictIter1 = zip([[1, 2, 3], [4, 5]], { mode: 'strict' });
|
| 151 |
+
strictIter1.next(); // [1, 4]
|
| 152 |
+
strictIter1.next(); // [2, 5]
|
| 153 |
+
s2t['throws'](function () { strictIter1.next(); }, TypeError, 'strict mode throws when first iterator has more');
|
| 154 |
+
|
| 155 |
+
var strictIter2 = zip([[1, 2], [3, 4, 5]], { mode: 'strict' });
|
| 156 |
+
strictIter2.next(); // [1, 3]
|
| 157 |
+
strictIter2.next(); // [2, 4]
|
| 158 |
+
s2t['throws'](function () { strictIter2.next(); }, TypeError, 'strict mode throws when second iterator has more');
|
| 159 |
+
|
| 160 |
+
s2t.end();
|
| 161 |
+
});
|
| 162 |
+
|
| 163 |
+
st.test('262: padding option validation', function (s2t) {
|
| 164 |
+
// padding is only used in longest mode
|
| 165 |
+
s2t.doesNotThrow(function () { zip([[1], [2]], { mode: 'shortest', padding: null }); }, 'invalid padding ignored in shortest mode');
|
| 166 |
+
s2t.doesNotThrow(function () { zip([[1], [2]], { mode: 'strict', padding: null }); }, 'invalid padding ignored in strict mode');
|
| 167 |
+
|
| 168 |
+
// invalid padding in longest mode
|
| 169 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: 'longest', padding: null }); }, TypeError, 'null padding throws in longest mode');
|
| 170 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: 'longest', padding: 'abc' }); }, TypeError, 'string padding throws in longest mode');
|
| 171 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: 'longest', padding: 123 }); }, TypeError, 'number padding throws in longest mode');
|
| 172 |
+
s2t['throws'](function () { zip([[1], [2]], { mode: 'longest', padding: true }); }, TypeError, 'boolean padding throws in longest mode');
|
| 173 |
+
|
| 174 |
+
s2t.end();
|
| 175 |
+
});
|
| 176 |
+
|
| 177 |
+
st.test('262: result is iterator', function (s2t) {
|
| 178 |
+
var zipIter = zip([[1, 2], [3, 4]]);
|
| 179 |
+
s2t.equal(typeof zipIter.next, 'function', 'has next method');
|
| 180 |
+
s2t.equal(typeof zipIter[Symbol.iterator], 'function', 'has Symbol.iterator method');
|
| 181 |
+
s2t.equal(zipIter[Symbol.iterator](), zipIter, 'Symbol.iterator returns itself');
|
| 182 |
+
|
| 183 |
+
s2t.end();
|
| 184 |
+
});
|
| 185 |
+
|
| 186 |
+
st.test('262: return closes all underlying iterators', function (s2t) {
|
| 187 |
+
var return1Calls = 0;
|
| 188 |
+
var return2Calls = 0;
|
| 189 |
+
|
| 190 |
+
var iter1 = {
|
| 191 |
+
next: function () { return { done: false, value: 1 }; },
|
| 192 |
+
'return': function () {
|
| 193 |
+
return1Calls += 1;
|
| 194 |
+
return { done: true, value: undefined };
|
| 195 |
+
}
|
| 196 |
+
};
|
| 197 |
+
iter1[Symbol.iterator] = function () { return iter1; };
|
| 198 |
+
|
| 199 |
+
var iter2 = {
|
| 200 |
+
next: function () { return { done: false, value: 2 }; },
|
| 201 |
+
'return': function () {
|
| 202 |
+
return2Calls += 1;
|
| 203 |
+
return { done: true, value: undefined };
|
| 204 |
+
}
|
| 205 |
+
};
|
| 206 |
+
iter2[Symbol.iterator] = function () { return iter2; };
|
| 207 |
+
|
| 208 |
+
var zipIter = zip([iter1, iter2]);
|
| 209 |
+
zipIter.next();
|
| 210 |
+
s2t.equal(return1Calls, 0, 'return not called before calling return()');
|
| 211 |
+
s2t.equal(return2Calls, 0, 'return not called before calling return()');
|
| 212 |
+
|
| 213 |
+
zipIter['return']();
|
| 214 |
+
s2t.equal(return1Calls, 1, 'iter1.return called once');
|
| 215 |
+
s2t.equal(return2Calls, 1, 'iter2.return called once');
|
| 216 |
+
|
| 217 |
+
s2t.end();
|
| 218 |
+
});
|
| 219 |
+
|
| 220 |
+
st.test('262: next method throws closes other iterators', function (s2t) {
|
| 221 |
+
var return2Calls = 0;
|
| 222 |
+
|
| 223 |
+
var iter1 = {
|
| 224 |
+
next: function () { throw new EvalError('iter1 next threw'); }
|
| 225 |
+
};
|
| 226 |
+
iter1[Symbol.iterator] = function () { return iter1; };
|
| 227 |
+
|
| 228 |
+
var iter2 = {
|
| 229 |
+
next: function () { return { done: false, value: 2 }; },
|
| 230 |
+
'return': function () {
|
| 231 |
+
return2Calls += 1;
|
| 232 |
+
return { done: true, value: undefined };
|
| 233 |
+
}
|
| 234 |
+
};
|
| 235 |
+
iter2[Symbol.iterator] = function () { return iter2; };
|
| 236 |
+
|
| 237 |
+
var zipIter = zip([iter1, iter2]);
|
| 238 |
+
s2t['throws'](function () { zipIter.next(); }, EvalError, 'throws error from iter1.next');
|
| 239 |
+
s2t.equal(return2Calls, 1, 'iter2.return called when iter1.next throws');
|
| 240 |
+
|
| 241 |
+
s2t.end();
|
| 242 |
+
});
|
| 243 |
+
|
| 244 |
+
st.end();
|
| 245 |
+
});
|
| 246 |
+
},
|
| 247 |
+
index: function () {
|
| 248 |
+
test('Iterator.zip: index', function (t) {
|
| 249 |
+
module.exports.tests(index, 'Iterator.zip', t);
|
| 250 |
+
|
| 251 |
+
t.end();
|
| 252 |
+
});
|
| 253 |
+
},
|
| 254 |
+
implementation: function () {
|
| 255 |
+
test('Iterator.zip: implementation', function (t) {
|
| 256 |
+
module.exports.tests(impl, 'Iterator.zip', t);
|
| 257 |
+
|
| 258 |
+
t.end();
|
| 259 |
+
});
|
| 260 |
+
},
|
| 261 |
+
shimmed: function () {
|
| 262 |
+
test('Iterator.zip: shimmed', function (t) {
|
| 263 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 264 |
+
st.equal(Iterator.zip.name, 'zip', 'Iterator.zip has name "zip"');
|
| 265 |
+
st.end();
|
| 266 |
+
});
|
| 267 |
+
|
| 268 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 269 |
+
et.equal(false, isEnumerable.call(Iterator, 'zip'), 'Iterator.zip is not enumerable');
|
| 270 |
+
et.end();
|
| 271 |
+
});
|
| 272 |
+
|
| 273 |
+
module.exports.tests(callBind(Iterator.zip, Iterator), 'Iterator.zip', t);
|
| 274 |
+
|
| 275 |
+
t.end();
|
| 276 |
+
});
|
| 277 |
+
}
|
| 278 |
+
};
|
node_modules/es-iterator-helpers/test/Iterator.zipKeyed.js
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var defineProperties = require('define-properties');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 7 |
+
var forEach = require('for-each');
|
| 8 |
+
var debug = require('object-inspect');
|
| 9 |
+
var v = require('es-value-fixtures');
|
| 10 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 11 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 12 |
+
var mockProperty = require('mock-property');
|
| 13 |
+
|
| 14 |
+
var index = require('../Iterator.zipKeyed');
|
| 15 |
+
var impl = require('../Iterator.zipKeyed/implementation');
|
| 16 |
+
var from = require('../Iterator.from/polyfill')();
|
| 17 |
+
|
| 18 |
+
var testIterator = require('./helpers/testIterator');
|
| 19 |
+
|
| 20 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 21 |
+
|
| 22 |
+
module.exports = {
|
| 23 |
+
tests: function (zipKeyed, name, t) {
|
| 24 |
+
t['throws'](
|
| 25 |
+
function () { return new zipKeyed(); }, // eslint-disable-line new-cap
|
| 26 |
+
TypeError,
|
| 27 |
+
'`' + name + '` itself is not a constructor'
|
| 28 |
+
);
|
| 29 |
+
t['throws'](
|
| 30 |
+
function () { return new zipKeyed({}); }, // eslint-disable-line new-cap
|
| 31 |
+
TypeError,
|
| 32 |
+
'`' + name + '` itself is not a constructor, with an argument'
|
| 33 |
+
);
|
| 34 |
+
|
| 35 |
+
forEach(v.primitives, function (primitive) {
|
| 36 |
+
t['throws'](
|
| 37 |
+
function () { zipKeyed(primitive); },
|
| 38 |
+
TypeError,
|
| 39 |
+
debug(primitive) + ' is not an Object'
|
| 40 |
+
);
|
| 41 |
+
if (primitive != null) {
|
| 42 |
+
t['throws'](
|
| 43 |
+
function () { zipKeyed({ a: primitive }); },
|
| 44 |
+
TypeError,
|
| 45 |
+
'key "a" on iterables object is ' + debug(primitive) + ' which is not an iterable Object'
|
| 46 |
+
);
|
| 47 |
+
}
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
forEach(v.objects, function (nonIterator) {
|
| 51 |
+
t.doesNotThrow(function () { zipKeyed({ a: nonIterator }); }, 'does not throw until `.next()`');
|
| 52 |
+
|
| 53 |
+
t['throws'](
|
| 54 |
+
function () { zipKeyed({ a: nonIterator }).next(); },
|
| 55 |
+
TypeError,
|
| 56 |
+
'key "a" on iterables object is ' + debug(nonIterator) + ' which is not an iterable Object'
|
| 57 |
+
);
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
|
| 61 |
+
forEach(v.nonFunctions, function (nonFunction) {
|
| 62 |
+
if (nonFunction != null) {
|
| 63 |
+
var badIterable = {};
|
| 64 |
+
badIterable[Symbol.iterator] = nonFunction;
|
| 65 |
+
st['throws'](
|
| 66 |
+
function () { zipKeyed({ a: [], b: badIterable, c: [] }).next(); },
|
| 67 |
+
TypeError,
|
| 68 |
+
'key "b" on iterables object is ' + debug(badIterable) + ' is not a function'
|
| 69 |
+
);
|
| 70 |
+
}
|
| 71 |
+
});
|
| 72 |
+
|
| 73 |
+
forEach(v.strings, function (string) {
|
| 74 |
+
st['throws'](
|
| 75 |
+
function () { zipKeyed({ a: string }); },
|
| 76 |
+
TypeError,
|
| 77 |
+
'key "a" on iterables object is an iterable primitive, but non-objects are not considered iterable'
|
| 78 |
+
);
|
| 79 |
+
});
|
| 80 |
+
|
| 81 |
+
st.test('real iterators', { skip: !hasSymbols }, function (s2t) {
|
| 82 |
+
var iter = [['a', 1], ['b', 2]][Symbol.iterator]();
|
| 83 |
+
var iterator = zipKeyed({ a: iter, b: ['a', 3], c: ['b', 4] });
|
| 84 |
+
|
| 85 |
+
testIterator(
|
| 86 |
+
iterator,
|
| 87 |
+
[
|
| 88 |
+
{ __proto__: null, a: ['a', 1], b: 'a', c: 'b' },
|
| 89 |
+
{ __proto__: null, a: ['b', 2], b: 3, c: 4 }
|
| 90 |
+
],
|
| 91 |
+
s2t,
|
| 92 |
+
'array iterator + array yields combined results'
|
| 93 |
+
);
|
| 94 |
+
|
| 95 |
+
s2t.end();
|
| 96 |
+
});
|
| 97 |
+
|
| 98 |
+
st.test('observability in a replaced String iterator', function (s2t) {
|
| 99 |
+
var originalStringIterator = String.prototype[Symbol.iterator];
|
| 100 |
+
var observedType;
|
| 101 |
+
s2t.teardown(mockProperty(String.prototype, Symbol.iterator, {
|
| 102 |
+
get: function () {
|
| 103 |
+
'use strict'; // eslint-disable-line strict, lines-around-directive
|
| 104 |
+
|
| 105 |
+
observedType = typeof this;
|
| 106 |
+
return originalStringIterator;
|
| 107 |
+
}
|
| 108 |
+
}));
|
| 109 |
+
|
| 110 |
+
zipKeyed([from('')]);
|
| 111 |
+
s2t.equal(observedType, 'string', 'string primitive -> primitive receiver in Symbol.iterator getter');
|
| 112 |
+
zipKeyed([from(Object(''))]);
|
| 113 |
+
s2t.equal(observedType, 'object', 'boxed string -> boxed string in Symbol.iterator getter');
|
| 114 |
+
|
| 115 |
+
s2t.end();
|
| 116 |
+
});
|
| 117 |
+
|
| 118 |
+
st.test('262: mode option validation', function (s2t) {
|
| 119 |
+
// valid modes should not throw
|
| 120 |
+
s2t.doesNotThrow(function () { zipKeyed({ a: [1], b: [2] }); }, 'undefined mode is valid');
|
| 121 |
+
s2t.doesNotThrow(function () { zipKeyed({ a: [1], b: [2] }, { mode: undefined }); }, 'explicit undefined mode is valid');
|
| 122 |
+
s2t.doesNotThrow(function () { zipKeyed({ a: [1], b: [2] }, { mode: 'shortest' }); }, '"shortest" mode is valid');
|
| 123 |
+
s2t.doesNotThrow(function () { zipKeyed({ a: [1], b: [2] }, { mode: 'longest' }); }, '"longest" mode is valid');
|
| 124 |
+
s2t.doesNotThrow(function () { zipKeyed({ a: [1], b: [2] }, { mode: 'strict' }); }, '"strict" mode is valid');
|
| 125 |
+
|
| 126 |
+
// invalid modes should throw TypeError
|
| 127 |
+
s2t['throws'](function () { zipKeyed({ a: [1], b: [2] }, { mode: null }); }, TypeError, 'null mode throws TypeError');
|
| 128 |
+
s2t['throws'](function () { zipKeyed({ a: [1], b: [2] }, { mode: false }); }, TypeError, 'false mode throws TypeError');
|
| 129 |
+
s2t['throws'](function () { zipKeyed({ a: [1], b: [2] }, { mode: '' }); }, TypeError, 'empty string mode throws TypeError');
|
| 130 |
+
s2t['throws'](function () { zipKeyed({ a: [1], b: [2] }, { mode: 'short' }); }, TypeError, '"short" mode throws TypeError');
|
| 131 |
+
s2t['throws'](function () { zipKeyed({ a: [1], b: [2] }, { mode: 'long' }); }, TypeError, '"long" mode throws TypeError');
|
| 132 |
+
s2t['throws'](function () { zipKeyed({ a: [1], b: [2] }, { mode: {} }); }, TypeError, 'object mode throws TypeError');
|
| 133 |
+
|
| 134 |
+
s2t.end();
|
| 135 |
+
});
|
| 136 |
+
|
| 137 |
+
st.test('262: basic shortest mode', function (s2t) {
|
| 138 |
+
// shortest mode (default) stops at minimum length
|
| 139 |
+
var iter1 = zipKeyed({ a: [1, 2, 3], b: [4, 5] });
|
| 140 |
+
var results1 = [];
|
| 141 |
+
var r;
|
| 142 |
+
while (!(r = iter1.next()).done) {
|
| 143 |
+
results1.push(r.value);
|
| 144 |
+
}
|
| 145 |
+
s2t.equal(results1.length, 2, 'shortest mode stops at shorter iterator');
|
| 146 |
+
s2t.deepEqual(results1[0], { __proto__: null, a: 1, b: 4 }, 'first result');
|
| 147 |
+
s2t.deepEqual(results1[1], { __proto__: null, a: 2, b: 5 }, 'second result');
|
| 148 |
+
|
| 149 |
+
s2t.end();
|
| 150 |
+
});
|
| 151 |
+
|
| 152 |
+
st.test('262: basic longest mode', function (s2t) {
|
| 153 |
+
// longest mode continues with padding for exhausted iterators
|
| 154 |
+
var iter1 = zipKeyed({ a: [1, 2, 3], b: [4, 5] }, { mode: 'longest' });
|
| 155 |
+
var result1 = iter1.next().value;
|
| 156 |
+
s2t.deepEqual(result1, { __proto__: null, a: 1, b: 4 }, 'first result has both keys');
|
| 157 |
+
|
| 158 |
+
var result2 = iter1.next().value;
|
| 159 |
+
s2t.deepEqual(result2, { __proto__: null, a: 2, b: 5 }, 'second result has both keys');
|
| 160 |
+
|
| 161 |
+
var result3 = iter1.next().value;
|
| 162 |
+
s2t.deepEqual(result3, { __proto__: null, a: 3, b: undefined }, 'third result has a with value and b with undefined');
|
| 163 |
+
|
| 164 |
+
var done = iter1.next();
|
| 165 |
+
s2t.equal(done.done, true, 'iterator is done after third result');
|
| 166 |
+
|
| 167 |
+
s2t.end();
|
| 168 |
+
});
|
| 169 |
+
|
| 170 |
+
st.test('262: basic strict mode', function (s2t) {
|
| 171 |
+
// strict mode throws when lengths differ
|
| 172 |
+
var strictIter = zipKeyed({ a: [1, 2, 3], b: [4, 5] }, { mode: 'strict' });
|
| 173 |
+
strictIter.next(); // { a: 1, b: 4 }
|
| 174 |
+
strictIter.next(); // { a: 2, b: 5 }
|
| 175 |
+
s2t['throws'](function () { strictIter.next(); }, TypeError, 'strict mode throws when lengths differ');
|
| 176 |
+
|
| 177 |
+
s2t.end();
|
| 178 |
+
});
|
| 179 |
+
|
| 180 |
+
st.test('262: symbol keys are used', function (s2t) {
|
| 181 |
+
var symbolA = Symbol('a');
|
| 182 |
+
var iterables = {};
|
| 183 |
+
iterables[symbolA] = ['value for symbol'];
|
| 184 |
+
iterables.b = ['value for b'];
|
| 185 |
+
|
| 186 |
+
var iter = zipKeyed(iterables);
|
| 187 |
+
var result = iter.next().value;
|
| 188 |
+
|
| 189 |
+
s2t.equal(Object.getPrototypeOf(result), null, 'result has null prototype');
|
| 190 |
+
s2t.ok(Object.prototype.hasOwnProperty.call(result, symbolA), 'result has symbol key');
|
| 191 |
+
s2t.ok(Object.prototype.hasOwnProperty.call(result, 'b'), 'result has string key');
|
| 192 |
+
s2t.equal(result[symbolA], 'value for symbol', 'symbol key has correct value');
|
| 193 |
+
s2t.equal(result.b, 'value for b', 'string key has correct value');
|
| 194 |
+
|
| 195 |
+
s2t.end();
|
| 196 |
+
});
|
| 197 |
+
|
| 198 |
+
st.test('262: inherited properties are skipped', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 199 |
+
var parentAccessed = false;
|
| 200 |
+
var parent = {};
|
| 201 |
+
Object.defineProperty(parent, 'inherited', {
|
| 202 |
+
get: function () {
|
| 203 |
+
parentAccessed = true;
|
| 204 |
+
throw new Error('inherited property should not be accessed');
|
| 205 |
+
},
|
| 206 |
+
enumerable: true,
|
| 207 |
+
configurable: true
|
| 208 |
+
});
|
| 209 |
+
|
| 210 |
+
var iterables = Object.create(parent);
|
| 211 |
+
iterables.own = ['own value'];
|
| 212 |
+
|
| 213 |
+
var iter = zipKeyed(iterables);
|
| 214 |
+
var result = iter.next().value;
|
| 215 |
+
|
| 216 |
+
s2t.equal(parentAccessed, false, 'inherited property getter not called');
|
| 217 |
+
s2t.ok(Object.prototype.hasOwnProperty.call(result, 'own'), 'result has own key');
|
| 218 |
+
s2t.notOk(Object.prototype.hasOwnProperty.call(result, 'inherited'), 'result does not have inherited key');
|
| 219 |
+
s2t.equal(result.own, 'own value', 'own key has correct value');
|
| 220 |
+
|
| 221 |
+
s2t.end();
|
| 222 |
+
});
|
| 223 |
+
|
| 224 |
+
st.test('262: non-enumerable properties are skipped', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 225 |
+
var iterables = {};
|
| 226 |
+
Object.defineProperty(iterables, 'nonEnum', {
|
| 227 |
+
value: ['non-enum value'],
|
| 228 |
+
enumerable: false,
|
| 229 |
+
configurable: true
|
| 230 |
+
});
|
| 231 |
+
iterables.enumerable = ['enum value'];
|
| 232 |
+
|
| 233 |
+
var iter = zipKeyed(iterables);
|
| 234 |
+
var result = iter.next().value;
|
| 235 |
+
|
| 236 |
+
s2t.notOk(Object.prototype.hasOwnProperty.call(result, 'nonEnum'), 'result does not have non-enumerable key');
|
| 237 |
+
s2t.ok(Object.prototype.hasOwnProperty.call(result, 'enumerable'), 'result has enumerable key');
|
| 238 |
+
|
| 239 |
+
s2t.end();
|
| 240 |
+
});
|
| 241 |
+
|
| 242 |
+
// Note: The "deleted properties" test is skipped as the current implementation
|
| 243 |
+
// doesn't handle dynamic property deletion during iteration correctly
|
| 244 |
+
|
| 245 |
+
st.test('262: result object has null prototype', function (s2t) {
|
| 246 |
+
var iter = zipKeyed({ a: [1], b: [2] });
|
| 247 |
+
var result = iter.next().value;
|
| 248 |
+
|
| 249 |
+
s2t.equal(Object.getPrototypeOf(result), null, 'result has null prototype');
|
| 250 |
+
|
| 251 |
+
s2t.end();
|
| 252 |
+
});
|
| 253 |
+
|
| 254 |
+
st.test('262: result object has default attributes', { skip: !hasPropertyDescriptors }, function (s2t) {
|
| 255 |
+
var iter = zipKeyed({ a: [1], b: [2] });
|
| 256 |
+
var result = iter.next().value;
|
| 257 |
+
|
| 258 |
+
var descA = Object.getOwnPropertyDescriptor(result, 'a');
|
| 259 |
+
var descB = Object.getOwnPropertyDescriptor(result, 'b');
|
| 260 |
+
|
| 261 |
+
s2t.equal(descA.writable, true, 'property a is writable');
|
| 262 |
+
s2t.equal(descA.enumerable, true, 'property a is enumerable');
|
| 263 |
+
s2t.equal(descA.configurable, true, 'property a is configurable');
|
| 264 |
+
|
| 265 |
+
s2t.equal(descB.writable, true, 'property b is writable');
|
| 266 |
+
s2t.equal(descB.enumerable, true, 'property b is enumerable');
|
| 267 |
+
s2t.equal(descB.configurable, true, 'property b is configurable');
|
| 268 |
+
|
| 269 |
+
s2t.end();
|
| 270 |
+
});
|
| 271 |
+
|
| 272 |
+
st.test('262: result is iterator', function (s2t) {
|
| 273 |
+
var zipKeyedIter = zipKeyed({ a: [1, 2], b: [3, 4] });
|
| 274 |
+
s2t.equal(typeof zipKeyedIter.next, 'function', 'has next method');
|
| 275 |
+
s2t.equal(typeof zipKeyedIter[Symbol.iterator], 'function', 'has Symbol.iterator method');
|
| 276 |
+
s2t.equal(zipKeyedIter[Symbol.iterator](), zipKeyedIter, 'Symbol.iterator returns itself');
|
| 277 |
+
|
| 278 |
+
s2t.end();
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
st.test('262: return closes all underlying iterators', function (s2t) {
|
| 282 |
+
var returnACalls = 0;
|
| 283 |
+
var returnBCalls = 0;
|
| 284 |
+
|
| 285 |
+
var iterA = {
|
| 286 |
+
next: function () { return { done: false, value: 1 }; },
|
| 287 |
+
'return': function () {
|
| 288 |
+
returnACalls += 1;
|
| 289 |
+
return { done: true, value: undefined };
|
| 290 |
+
}
|
| 291 |
+
};
|
| 292 |
+
iterA[Symbol.iterator] = function () { return iterA; };
|
| 293 |
+
|
| 294 |
+
var iterB = {
|
| 295 |
+
next: function () { return { done: false, value: 2 }; },
|
| 296 |
+
'return': function () {
|
| 297 |
+
returnBCalls += 1;
|
| 298 |
+
return { done: true, value: undefined };
|
| 299 |
+
}
|
| 300 |
+
};
|
| 301 |
+
iterB[Symbol.iterator] = function () { return iterB; };
|
| 302 |
+
|
| 303 |
+
var zkIter = zipKeyed({ a: iterA, b: iterB });
|
| 304 |
+
zkIter.next();
|
| 305 |
+
s2t.equal(returnACalls, 0, 'return not called on iterA before calling return()');
|
| 306 |
+
s2t.equal(returnBCalls, 0, 'return not called on iterB before calling return()');
|
| 307 |
+
|
| 308 |
+
zkIter['return']();
|
| 309 |
+
s2t.equal(returnACalls, 1, 'iterA.return called once');
|
| 310 |
+
s2t.equal(returnBCalls, 1, 'iterB.return called once');
|
| 311 |
+
|
| 312 |
+
s2t.end();
|
| 313 |
+
});
|
| 314 |
+
|
| 315 |
+
st.end();
|
| 316 |
+
});
|
| 317 |
+
},
|
| 318 |
+
index: function () {
|
| 319 |
+
test('Iterator.zipKeyed: index', function (t) {
|
| 320 |
+
module.exports.tests(index, 'Iterator.zipKeyed', t);
|
| 321 |
+
|
| 322 |
+
t.end();
|
| 323 |
+
});
|
| 324 |
+
},
|
| 325 |
+
implementation: function () {
|
| 326 |
+
test('Iterator.zipKeyed: implementation', function (t) {
|
| 327 |
+
module.exports.tests(impl, 'Iterator.zipKeyed', t);
|
| 328 |
+
|
| 329 |
+
t.end();
|
| 330 |
+
});
|
| 331 |
+
},
|
| 332 |
+
shimmed: function () {
|
| 333 |
+
test('Iterator.zipKeyed: shimmed', function (t) {
|
| 334 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 335 |
+
st.equal(Iterator.zipKeyed.name, 'zipKeyed', 'Iterator.zipKeyed has name "zipKeyed"');
|
| 336 |
+
st.end();
|
| 337 |
+
});
|
| 338 |
+
|
| 339 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 340 |
+
et.equal(false, isEnumerable.call(Iterator, 'zipKeyed'), 'Iterator.zipKeyed is not enumerable');
|
| 341 |
+
et.end();
|
| 342 |
+
});
|
| 343 |
+
|
| 344 |
+
module.exports.tests(callBind(Iterator.zipKeyed, Iterator), 'Iterator.zipKeyed', t);
|
| 345 |
+
|
| 346 |
+
t.end();
|
| 347 |
+
});
|
| 348 |
+
}
|
| 349 |
+
};
|
node_modules/es-iterator-helpers/test/helpers/testIterator.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var iterate = require('iterate-iterator');
|
| 4 |
+
|
| 5 |
+
module.exports = function testIterator(iterator, expected, t, msg) {
|
| 6 |
+
t.deepEqual(iterate(iterator), expected, 'iterator yields expected values: ' + msg);
|
| 7 |
+
};
|
node_modules/es-iterator-helpers/test/implementation.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var test = require('tape');
|
| 4 |
+
var forEach = require('for-each');
|
| 5 |
+
|
| 6 |
+
var shims = require('..');
|
| 7 |
+
|
| 8 |
+
forEach(shims, function (shim) {
|
| 9 |
+
var shimTests;
|
| 10 |
+
try {
|
| 11 |
+
shimTests = require('./' + shim); // eslint-disable-line global-require, import/no-dynamic-require
|
| 12 |
+
} catch (e) {
|
| 13 |
+
test(shim + ': implementation', { todo: true });
|
| 14 |
+
}
|
| 15 |
+
if (shimTests) {
|
| 16 |
+
shimTests.implementation();
|
| 17 |
+
}
|
| 18 |
+
});
|
node_modules/es-iterator-helpers/test/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var test = require('tape');
|
| 4 |
+
var forEach = require('for-each');
|
| 5 |
+
|
| 6 |
+
var shims = require('..');
|
| 7 |
+
|
| 8 |
+
forEach(shims, function (shim) {
|
| 9 |
+
var shimTests;
|
| 10 |
+
try {
|
| 11 |
+
shimTests = require('./' + shim); // eslint-disable-line global-require, import/no-dynamic-require
|
| 12 |
+
} catch (e) {
|
| 13 |
+
console.error(e);
|
| 14 |
+
test(shim + ': index', { todo: true });
|
| 15 |
+
}
|
| 16 |
+
if (shimTests) {
|
| 17 |
+
shimTests.index();
|
| 18 |
+
}
|
| 19 |
+
});
|
| 20 |
+
|
node_modules/es-iterator-helpers/test/shimmed.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
require('../auto');
|
| 4 |
+
|
| 5 |
+
var test = require('tape');
|
| 6 |
+
var forEach = require('for-each');
|
| 7 |
+
|
| 8 |
+
var shims = require('..');
|
| 9 |
+
|
| 10 |
+
forEach(shims, function (shim) {
|
| 11 |
+
var shimTests;
|
| 12 |
+
try {
|
| 13 |
+
shimTests = require('./' + shim); // eslint-disable-line global-require, import/no-dynamic-require
|
| 14 |
+
} catch (e) {
|
| 15 |
+
test(shim + ': shimmed', { todo: true });
|
| 16 |
+
}
|
| 17 |
+
if (shimTests) {
|
| 18 |
+
shimTests.shimmed();
|
| 19 |
+
}
|
| 20 |
+
});
|
| 21 |
+
|
| 22 |
+
test('integration', function (t) {
|
| 23 |
+
var seenMapEveryMap = [];
|
| 24 |
+
var seenMapEveryEvery = [];
|
| 25 |
+
var mapEveryResult = Iterator.from([1, 2, 3, 4, 5]).map(function (x) {
|
| 26 |
+
seenMapEveryMap.push(x);
|
| 27 |
+
return x * x;
|
| 28 |
+
}).every(function (x) {
|
| 29 |
+
seenMapEveryEvery.push(x);
|
| 30 |
+
return x < 10;
|
| 31 |
+
});
|
| 32 |
+
t.equal(mapEveryResult, false, 'map + every: every predicate returned false nonzero times');
|
| 33 |
+
t.deepEqual(seenMapEveryMap, [1, 2, 3, 4], 'map + every, map: all values are seen until after the first one that is > 10 when squared');
|
| 34 |
+
t.deepEqual(seenMapEveryEvery, [1, 4, 9, 16], 'map + every, every: all values are seen until after the first one that is > 10 when squared');
|
| 35 |
+
|
| 36 |
+
var seenMapSomeMap = [];
|
| 37 |
+
var seenMapSomeSome = [];
|
| 38 |
+
var mapSomeResult = Iterator.from([1, 2, 3, 4, 5]).map(function (x) {
|
| 39 |
+
seenMapSomeMap.push(x);
|
| 40 |
+
return x * x;
|
| 41 |
+
}).some(function (x) {
|
| 42 |
+
seenMapSomeSome.push(x);
|
| 43 |
+
return x > 10;
|
| 44 |
+
});
|
| 45 |
+
t.equal(mapSomeResult, true, 'map + some: some predicate returned true nonzero times');
|
| 46 |
+
t.deepEqual(seenMapSomeMap, [1, 2, 3, 4], 'map + some, map: all values are seen until after the first one that is > 10 when squared');
|
| 47 |
+
t.deepEqual(seenMapSomeSome, [1, 4, 9, 16], 'map + some, some: all values are seen until after the first one that is > 10 when squared');
|
| 48 |
+
|
| 49 |
+
var seenMapFind = [];
|
| 50 |
+
var mapFindResult = Iterator.from([1, 2, 3, 4, 5]).map(function (x) {
|
| 51 |
+
seenMapFind.push(x);
|
| 52 |
+
return x * x;
|
| 53 |
+
}).find(function (x) {
|
| 54 |
+
return x > 10;
|
| 55 |
+
});
|
| 56 |
+
t.equal(mapFindResult, 16, 'map + find: find found the first mapped value over 10');
|
| 57 |
+
t.deepEqual(seenMapFind, [1, 2, 3, 4], 'map + find: all values are seen until after the first one that is > 10 when squared');
|
| 58 |
+
|
| 59 |
+
var seenFilterEvery = [];
|
| 60 |
+
var filterEveryResult = Iterator.from([1, 2, 3, 4, 5]).filter(function (x) {
|
| 61 |
+
seenFilterEvery.push(x);
|
| 62 |
+
return x;
|
| 63 |
+
}).every(function (x) {
|
| 64 |
+
return x <= 3;
|
| 65 |
+
});
|
| 66 |
+
t.equal(filterEveryResult, false, 'filter + every: every predicate returned false nonzero times');
|
| 67 |
+
t.deepEqual(seenMapFind, [1, 2, 3, 4], 'filter + every: all values are seen until after the first one that is > 10 when squared');
|
| 68 |
+
|
| 69 |
+
t.end();
|
| 70 |
+
});
|
node_modules/es-iterator-helpers/test/tests.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var data = {
|
| 4 |
+
anchor: { arg: 'bar"baz"', expected: '<a name="bar"baz"">foo</a>' },
|
| 5 |
+
big: '<big>foo</big>',
|
| 6 |
+
blink: '<blink>foo</blink>',
|
| 7 |
+
bold: '<b>foo</b>',
|
| 8 |
+
fixed: '<tt>foo</tt>',
|
| 9 |
+
fontcolor: { arg: 'blue"red"green', expected: '<font color="blue"red"green">foo</font>' },
|
| 10 |
+
fontsize: { arg: '10"large"small', expected: '<font size="10"large"small">foo</font>' },
|
| 11 |
+
italics: '<i>foo</i>',
|
| 12 |
+
link: { arg: 'url"http://"', expected: '<a href="url"http://"">foo</a>' },
|
| 13 |
+
small: '<small>foo</small>',
|
| 14 |
+
strike: '<strike>foo</strike>',
|
| 15 |
+
sub: '<sub>foo</sub>',
|
| 16 |
+
sup: '<sup>foo</sup>'
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
module.exports = function (method, name, t) {
|
| 20 |
+
var result = data[name] || {};
|
| 21 |
+
var expected = typeof result === 'string' ? result : result.expected;
|
| 22 |
+
var actual = typeof result === 'string' ? method('foo') : method('foo', result.arg);
|
| 23 |
+
|
| 24 |
+
t.equal(actual, expected, name + ': got expected result');
|
| 25 |
+
};
|
node_modules/es-module-lexer/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
-----------
|
| 3 |
+
|
| 4 |
+
Copyright (C) 2018-2022 Guy Bedford
|
| 5 |
+
|
| 6 |
+
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:
|
| 7 |
+
|
| 8 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 9 |
+
|
| 10 |
+
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 LIAB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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ES Module Lexer
|
| 2 |
+
|
| 3 |
+
[![Build Status][actions-image]][actions-url]
|
| 4 |
+
|
| 5 |
+
A JS module syntax lexer used in [es-module-shims](https://github.com/guybedford/es-module-shims).
|
| 6 |
+
|
| 7 |
+
Outputs the list of exports and locations of import specifiers, including dynamic import and import meta handling.
|
| 8 |
+
|
| 9 |
+
Supports new syntax features including import attributes and source phase imports.
|
| 10 |
+
|
| 11 |
+
A very small single JS file (4KiB gzipped) that includes inlined Web Assembly for very fast source analysis of ECMAScript module syntax only.
|
| 12 |
+
|
| 13 |
+
For an example of the performance, Angular 1 (720KiB) is fully parsed in 5ms, in comparison to the fastest JS parser, Acorn which takes over 100ms.
|
| 14 |
+
|
| 15 |
+
_Comprehensively handles the JS language grammar while remaining small and fast. - ~10ms per MB of JS cold and ~5ms per MB of JS warm, [see benchmarks](#benchmarks) for more info._
|
| 16 |
+
|
| 17 |
+
> [Built with](https://github.com/guybedford/es-module-lexer/blob/main/chompfile.toml) [Chomp](https://chompbuild.com/)
|
| 18 |
+
|
| 19 |
+
### Usage
|
| 20 |
+
|
| 21 |
+
```
|
| 22 |
+
npm install es-module-lexer
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
See [src/lexer.ts](src/lexer.ts) for the type definitions.
|
| 26 |
+
|
| 27 |
+
For use in CommonJS:
|
| 28 |
+
|
| 29 |
+
```js
|
| 30 |
+
const { init, parse } = require('es-module-lexer');
|
| 31 |
+
|
| 32 |
+
(async () => {
|
| 33 |
+
// either await init, or call parse asynchronously
|
| 34 |
+
// this is necessary for the Web Assembly boot
|
| 35 |
+
await init;
|
| 36 |
+
|
| 37 |
+
const source = 'export var p = 5';
|
| 38 |
+
const [imports, exports] = parse(source);
|
| 39 |
+
|
| 40 |
+
// Returns "p"
|
| 41 |
+
source.slice(exports[0].s, exports[0].e);
|
| 42 |
+
// Returns "p"
|
| 43 |
+
source.slice(exports[0].ls, exports[0].le);
|
| 44 |
+
})();
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
An ES module version is also available:
|
| 48 |
+
|
| 49 |
+
```js
|
| 50 |
+
import { init, parse } from 'es-module-lexer';
|
| 51 |
+
|
| 52 |
+
(async () => {
|
| 53 |
+
await init;
|
| 54 |
+
|
| 55 |
+
const source = `
|
| 56 |
+
import { name } from 'mod\\u1011';
|
| 57 |
+
import json from './json.json' assert { type: 'json' }
|
| 58 |
+
export var p = 5;
|
| 59 |
+
export function q () {
|
| 60 |
+
|
| 61 |
+
};
|
| 62 |
+
export { x as 'external name' } from 'external';
|
| 63 |
+
|
| 64 |
+
// Comments provided to demonstrate edge cases
|
| 65 |
+
import /*comment!*/ ( 'asdf', { assert: { type: 'json' }});
|
| 66 |
+
import /*comment!*/.meta.asdf;
|
| 67 |
+
|
| 68 |
+
// Source phase imports:
|
| 69 |
+
import source mod from './mod.wasm';
|
| 70 |
+
import.source('./mod.wasm');
|
| 71 |
+
`;
|
| 72 |
+
|
| 73 |
+
const [imports, exports] = parse(source, 'optional-sourcename');
|
| 74 |
+
|
| 75 |
+
// Returns "modထ"
|
| 76 |
+
imports[0].n
|
| 77 |
+
// Returns "mod\u1011"
|
| 78 |
+
source.slice(imports[0].s, imports[0].e);
|
| 79 |
+
// "s" = start
|
| 80 |
+
// "e" = end
|
| 81 |
+
|
| 82 |
+
// Returns "import { name } from 'mod'"
|
| 83 |
+
source.slice(imports[0].ss, imports[0].se);
|
| 84 |
+
// "ss" = statement start
|
| 85 |
+
// "se" = statement end
|
| 86 |
+
|
| 87 |
+
// Returns "{ type: 'json' }"
|
| 88 |
+
source.slice(imports[1].a, imports[1].se);
|
| 89 |
+
// "a" = assert, -1 for no assertion
|
| 90 |
+
|
| 91 |
+
// Returns "external"
|
| 92 |
+
source.slice(imports[2].s, imports[2].e);
|
| 93 |
+
|
| 94 |
+
// Returns "p"
|
| 95 |
+
source.slice(exports[0].s, exports[0].e);
|
| 96 |
+
// Returns "p"
|
| 97 |
+
source.slice(exports[0].ls, exports[0].le);
|
| 98 |
+
// Returns "q"
|
| 99 |
+
source.slice(exports[1].s, exports[1].e);
|
| 100 |
+
// Returns "q"
|
| 101 |
+
source.slice(exports[1].ls, exports[1].le);
|
| 102 |
+
// Returns "'external name'"
|
| 103 |
+
source.slice(exports[2].s, exports[2].e);
|
| 104 |
+
// Returns -1
|
| 105 |
+
exports[2].ls;
|
| 106 |
+
// Returns -1
|
| 107 |
+
exports[2].le;
|
| 108 |
+
|
| 109 |
+
// Import type is provided by `t` value
|
| 110 |
+
// (1 for static, 2, for dynamic)
|
| 111 |
+
// Returns true
|
| 112 |
+
imports[2].t == 2;
|
| 113 |
+
|
| 114 |
+
// Returns "asdf" (only for string literal dynamic imports)
|
| 115 |
+
imports[2].n
|
| 116 |
+
// Returns "import /*comment!*/ ( 'asdf', { assert: { type: 'json' } })"
|
| 117 |
+
source.slice(imports[3].ss, imports[3].se);
|
| 118 |
+
// Returns "'asdf'"
|
| 119 |
+
source.slice(imports[3].s, imports[3].e);
|
| 120 |
+
// Returns "( 'asdf', { assert: { type: 'json' } })"
|
| 121 |
+
source.slice(imports[3].d, imports[3].se);
|
| 122 |
+
// Returns "{ assert: { type: 'json' } }"
|
| 123 |
+
source.slice(imports[3].a, imports[3].se - 1);
|
| 124 |
+
|
| 125 |
+
// For non-string dynamic import expressions:
|
| 126 |
+
// - n will be undefined
|
| 127 |
+
// - a is currently -1 even if there is an assertion
|
| 128 |
+
// - e is currently the character before the closing )
|
| 129 |
+
|
| 130 |
+
// For nested dynamic imports, the se value of the outer import is -1 as end tracking does not
|
| 131 |
+
// currently support nested dynamic immports
|
| 132 |
+
|
| 133 |
+
// import.meta is indicated by imports[3].d === -2
|
| 134 |
+
// Returns true
|
| 135 |
+
imports[4].d === -2;
|
| 136 |
+
// Returns "import /*comment!*/.meta"
|
| 137 |
+
source.slice(imports[4].s, imports[4].e);
|
| 138 |
+
// ss and se are the same for import meta
|
| 139 |
+
|
| 140 |
+
// Returns "'./mod.wasm'"
|
| 141 |
+
source.slice(imports[5].s, imports[5].e);
|
| 142 |
+
|
| 143 |
+
// Import type 4 and 5 for static and dynamic source phase
|
| 144 |
+
imports[5].t === 4;
|
| 145 |
+
imports[6].t === 5;
|
| 146 |
+
})();
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
### CSP asm.js Build
|
| 150 |
+
|
| 151 |
+
The default version of the library uses Wasm and (safe) eval usage for performance and a minimal footprint.
|
| 152 |
+
|
| 153 |
+
Neither of these represent security escalation possibilities since there are no execution string injection vectors, but that can still violate existing CSP policies for applications.
|
| 154 |
+
|
| 155 |
+
For a version that works with CSP eval disabled, use the `es-module-lexer/js` build:
|
| 156 |
+
|
| 157 |
+
```js
|
| 158 |
+
import { parse } from 'es-module-lexer/js';
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
Instead of Web Assembly, this uses an asm.js build which is almost as fast as the Wasm version ([see benchmarks below](#benchmarks)).
|
| 162 |
+
|
| 163 |
+
### Escape Sequences
|
| 164 |
+
|
| 165 |
+
To handle escape sequences in specifier strings, the `.n` field of imported specifiers will be provided where possible.
|
| 166 |
+
|
| 167 |
+
For dynamic import expressions, this field will be empty if not a valid JS string.
|
| 168 |
+
|
| 169 |
+
### Facade Detection
|
| 170 |
+
|
| 171 |
+
Facade modules that only use import / export syntax can be detected via the third return value:
|
| 172 |
+
|
| 173 |
+
```js
|
| 174 |
+
const [,, facade] = parse(`
|
| 175 |
+
export * from 'external';
|
| 176 |
+
import * as ns from 'external2';
|
| 177 |
+
export { a as b } from 'external3';
|
| 178 |
+
export { ns };
|
| 179 |
+
`);
|
| 180 |
+
facade === true;
|
| 181 |
+
```
|
| 182 |
+
|
| 183 |
+
### ESM Detection
|
| 184 |
+
|
| 185 |
+
Modules that uses ESM syntaxes can be detected via the fourth return value:
|
| 186 |
+
|
| 187 |
+
```js
|
| 188 |
+
const [,,, hasModuleSyntax] = parse(`
|
| 189 |
+
export {}
|
| 190 |
+
`);
|
| 191 |
+
hasModuleSyntax === true;
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
Dynamic imports are ignored since they can be used in Non-ESM files.
|
| 195 |
+
|
| 196 |
+
```js
|
| 197 |
+
const [,,, hasModuleSyntax] = parse(`
|
| 198 |
+
import('./foo.js')
|
| 199 |
+
`);
|
| 200 |
+
hasModuleSyntax === false;
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
### Environment Support
|
| 204 |
+
|
| 205 |
+
Node.js 10+, and [all browsers with Web Assembly support](https://caniuse.com/#feat=wasm).
|
| 206 |
+
|
| 207 |
+
### Grammar Support
|
| 208 |
+
|
| 209 |
+
* Token state parses all line comments, block comments, strings, template strings, blocks, parens and punctuators.
|
| 210 |
+
* Division operator / regex token ambiguity is handled via backtracking checks against punctuator prefixes, including closing brace or paren backtracking.
|
| 211 |
+
* Always correctly parses valid JS source, but may parse invalid JS source without errors.
|
| 212 |
+
|
| 213 |
+
### Limitations
|
| 214 |
+
|
| 215 |
+
The lexing approach is designed to deal with the full language grammar including RegEx / division operator ambiguity through backtracking and paren / brace tracking.
|
| 216 |
+
|
| 217 |
+
The only limitation to the reduced parser is that the "exports" list may not correctly gather all export identifiers in the following edge cases:
|
| 218 |
+
|
| 219 |
+
```js
|
| 220 |
+
// Only "a" is detected as an export, "q" isn't
|
| 221 |
+
export var a = 'asdf', q = z;
|
| 222 |
+
|
| 223 |
+
// "b" is not detected as an export
|
| 224 |
+
export var { a: b } = asdf;
|
| 225 |
+
```
|
| 226 |
+
|
| 227 |
+
The above cases are handled gracefully in that the lexer will keep going fine, it will just not properly detect the export names above.
|
| 228 |
+
|
| 229 |
+
### Benchmarks
|
| 230 |
+
|
| 231 |
+
Benchmarks can be run with `npm run bench`.
|
| 232 |
+
|
| 233 |
+
Current results for a high spec machine:
|
| 234 |
+
|
| 235 |
+
#### Wasm Build
|
| 236 |
+
|
| 237 |
+
```
|
| 238 |
+
Module load time
|
| 239 |
+
> 5ms
|
| 240 |
+
Cold Run, All Samples
|
| 241 |
+
test/samples/*.js (3123 KiB)
|
| 242 |
+
> 18ms
|
| 243 |
+
|
| 244 |
+
Warm Runs (average of 25 runs)
|
| 245 |
+
test/samples/angular.js (739 KiB)
|
| 246 |
+
> 3ms
|
| 247 |
+
test/samples/angular.min.js (188 KiB)
|
| 248 |
+
> 1ms
|
| 249 |
+
test/samples/d3.js (508 KiB)
|
| 250 |
+
> 3ms
|
| 251 |
+
test/samples/d3.min.js (274 KiB)
|
| 252 |
+
> 2ms
|
| 253 |
+
test/samples/magic-string.js (35 KiB)
|
| 254 |
+
> 0ms
|
| 255 |
+
test/samples/magic-string.min.js (20 KiB)
|
| 256 |
+
> 0ms
|
| 257 |
+
test/samples/rollup.js (929 KiB)
|
| 258 |
+
> 4.32ms
|
| 259 |
+
test/samples/rollup.min.js (429 KiB)
|
| 260 |
+
> 2.16ms
|
| 261 |
+
|
| 262 |
+
Warm Runs, All Samples (average of 25 runs)
|
| 263 |
+
test/samples/*.js (3123 KiB)
|
| 264 |
+
> 14.16ms
|
| 265 |
+
```
|
| 266 |
+
|
| 267 |
+
#### JS Build (asm.js)
|
| 268 |
+
|
| 269 |
+
```
|
| 270 |
+
Module load time
|
| 271 |
+
> 2ms
|
| 272 |
+
Cold Run, All Samples
|
| 273 |
+
test/samples/*.js (3123 KiB)
|
| 274 |
+
> 34ms
|
| 275 |
+
|
| 276 |
+
Warm Runs (average of 25 runs)
|
| 277 |
+
test/samples/angular.js (739 KiB)
|
| 278 |
+
> 3ms
|
| 279 |
+
test/samples/angular.min.js (188 KiB)
|
| 280 |
+
> 1ms
|
| 281 |
+
test/samples/d3.js (508 KiB)
|
| 282 |
+
> 3ms
|
| 283 |
+
test/samples/d3.min.js (274 KiB)
|
| 284 |
+
> 2ms
|
| 285 |
+
test/samples/magic-string.js (35 KiB)
|
| 286 |
+
> 0ms
|
| 287 |
+
test/samples/magic-string.min.js (20 KiB)
|
| 288 |
+
> 0ms
|
| 289 |
+
test/samples/rollup.js (929 KiB)
|
| 290 |
+
> 5ms
|
| 291 |
+
test/samples/rollup.min.js (429 KiB)
|
| 292 |
+
> 3.04ms
|
| 293 |
+
|
| 294 |
+
Warm Runs, All Samples (average of 25 runs)
|
| 295 |
+
test/samples/*.js (3123 KiB)
|
| 296 |
+
> 17.12ms
|
| 297 |
+
```
|
| 298 |
+
|
| 299 |
+
### Building
|
| 300 |
+
|
| 301 |
+
This project uses [Chomp](https://chompbuild.com) for building.
|
| 302 |
+
|
| 303 |
+
With Chomp installed, download the WASI SDK 12.0 from https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-12.
|
| 304 |
+
|
| 305 |
+
- [Linux](https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz)
|
| 306 |
+
- [Windows (MinGW)](https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-mingw.tar.gz)
|
| 307 |
+
- [macOS](https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz)
|
| 308 |
+
|
| 309 |
+
Locate the WASI-SDK as a sibling folder, or customize the path via the `WASI_PATH` environment variable.
|
| 310 |
+
|
| 311 |
+
Emscripten emsdk is also assumed to be a sibling folder or via the `EMSDK_PATH` environment variable.
|
| 312 |
+
|
| 313 |
+
Example setup:
|
| 314 |
+
|
| 315 |
+
```
|
| 316 |
+
git clone https://github.com:guybedford/es-module-lexer
|
| 317 |
+
git clone https://github.com/emscripten-core/emsdk
|
| 318 |
+
cd emsdk
|
| 319 |
+
git checkout 1.40.1-fastcomp
|
| 320 |
+
./emsdk install 1.40.1-fastcomp
|
| 321 |
+
cd ..
|
| 322 |
+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
|
| 323 |
+
gunzip wasi-sdk-12.0-linux.tar.gz
|
| 324 |
+
tar -xf wasi-sdk-12.0-linux.tar
|
| 325 |
+
mv wasi-sdk-12.0-linux.tar wasi-sdk-12.0
|
| 326 |
+
cargo install chompbuild
|
| 327 |
+
cd es-module-lexer
|
| 328 |
+
chomp test
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
For the `asm.js` build, git clone `emsdk` from is assumed to be a sibling folder as well.
|
| 332 |
+
|
| 333 |
+
### License
|
| 334 |
+
|
| 335 |
+
MIT
|
| 336 |
+
|
| 337 |
+
[actions-image]: https://github.com/guybedford/es-module-lexer/actions/workflows/build.yml/badge.svg
|
| 338 |
+
[actions-url]: https://github.com/guybedford/es-module-lexer/actions/workflows/build.yml
|
node_modules/es-module-lexer/dist/lexer.asm.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* es-module-lexer 1.7.0 */
|
| 2 |
+
let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++)}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8}},f="xportmportlassforetaourceeferromsyncunctionssertvoyiedelecontininstantybreareturdebuggeawaithrwhileifcatcfinallels";let t,c,n;export function parse(k,l="@"){t=k,c=l;const u=2*t.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,114)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),t=new e.Uint8Array(r),c=new e.Uint16Array(r),n=1040;function b(){var e=0,a=0,r=0,t=0,c=0,b=0,u=0;u=n;n=n+10240|0;i[812]=1;i[811]=0;s[403]=0;s[404]=0;f[71]=f[2];i[813]=0;f[70]=0;i[810]=0;f[72]=u+2048;f[73]=u;i[814]=0;e=(f[3]|0)+-2|0;f[74]=e;a=e+(f[68]<<1)|0;f[75]=a;e:while(1){r=e+2|0;f[74]=r;if(e>>>0>=a>>>0){t=18;break}a:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[404]|0)==0?H(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(k(),(i[812]|0)==0):0){t=9;break e}else t=17;break}case 105:{if(H(r)|0?(m(e+4|0,26,10)|0)==0:0){l();t=17}else t=17;break}case 59:{t=17;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{t=16;break e}}default:{t=16;break e}}}while(0);if((t|0)==17){t=0;f[71]=f[74]}e=f[74]|0;a=f[75]|0}if((t|0)==9){e=f[74]|0;f[71]=e;t=19}else if((t|0)==16){i[812]=0;f[74]=e;t=19}else if((t|0)==18)if(!(i[810]|0)){e=r;t=19}else e=0;do{if((t|0)==19){e:while(1){a=e+2|0;f[74]=a;if(e>>>0>=(f[75]|0)>>>0){t=92;break}a:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[404]|0)==0?H(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){k();t=91}else t=91;break}case 105:{if(H(a)|0?(m(e+4|0,26,10)|0)==0:0){l();t=91}else t=91;break}case 99:{if((H(a)|0?(m(e+4|0,36,8)|0)==0:0)?V(s[e+12>>1]|0)|0:0){i[814]=1;t=91}else t=91;break}case 40:{r=f[72]|0;e=s[404]|0;t=e&65535;f[r+(t<<3)>>2]=1;a=f[71]|0;s[404]=e+1<<16>>16;f[r+(t<<3)+4>>2]=a;t=91;break}case 41:{a=s[404]|0;if(!(a<<16>>16)){t=36;break e}r=a+-1<<16>>16;s[404]=r;t=s[403]|0;a=t&65535;if(t<<16>>16!=0?(f[(f[72]|0)+((r&65535)<<3)>>2]|0)==5:0){a=f[(f[73]|0)+(a+-1<<2)>>2]|0;r=a+4|0;if(!(f[r>>2]|0))f[r>>2]=(f[71]|0)+2;f[a+12>>2]=e+4;s[403]=t+-1<<16>>16;t=91}else t=91;break}case 123:{t=f[71]|0;r=f[65]|0;e=t;do{if((s[t>>1]|0)==41&(r|0)!=0?(f[r+4>>2]|0)==(t|0):0){a=f[66]|0;f[65]=a;if(!a){f[61]=0;break}else{f[a+32>>2]=0;break}}}while(0);r=f[72]|0;a=s[404]|0;t=a&65535;f[r+(t<<3)>>2]=(i[814]|0)==0?2:6;s[404]=a+1<<16>>16;f[r+(t<<3)+4>>2]=e;i[814]=0;t=91;break}case 125:{e=s[404]|0;if(!(e<<16>>16)){t=49;break e}r=f[72]|0;t=e+-1<<16>>16;s[404]=t;if((f[r+((t&65535)<<3)>>2]|0)==4){h();t=91}else t=91;break}case 39:{v(39);t=91;break}case 34:{v(34);t=91;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{e=f[71]|0;a=s[e>>1]|0;r:do{if(!(U(a)|0))if(a<<16>>16==41){r=s[404]|0;if(!(D(f[(f[72]|0)+((r&65535)<<3)+4>>2]|0)|0))t=65}else t=64;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){t=64;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){t=64;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){t=64;break r}else break r;default:break r}}while(0);if((t|0)==64){r=s[404]|0;t=65}r:do{if((t|0)==65){t=0;if(r<<16>>16!=0?(c=f[72]|0,b=(r&65535)+-1|0,a<<16>>16==102?(f[c+(b<<3)>>2]|0)==1:0):0){if((s[e+-2>>1]|0)==111?$(f[c+(b<<3)+4>>2]|0,44,3)|0:0)break}else t=69;if((t|0)==69?(0,a<<16>>16==125):0){t=f[72]|0;r=r&65535;if(p(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(o(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[813]|0)break r;break}default:{}}t=f[67]|0;if((t|0?e>>>0>=(f[t>>2]|0)>>>0:0)?e>>>0<=(f[t+4>>2]|0)>>>0:0){g();i[813]=0;t=91;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[71]=e;a=s[e>>1]|0}while(!(E(a)|0));if(F(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[71]=e}while(F(s[e>>1]|0)|0);if(j(e)|0){g();i[813]=0;t=91;break a}}i[813]=1;t=91;break a}}}while(0);g();i[813]=0;t=91;break a}}case 96:{r=f[72]|0;a=s[404]|0;t=a&65535;f[r+(t<<3)+4>>2]=f[71];s[404]=a+1<<16>>16;f[r+(t<<3)>>2]=3;h();t=91;break}default:t=91}}while(0);if((t|0)==91){t=0;f[71]=f[74]}e=f[74]|0}if((t|0)==36){T();e=0;break}else if((t|0)==49){T();e=0;break}else if((t|0)==92){e=(i[810]|0)==0?(s[403]|s[404])<<16>>16==0:0;break}}}while(0);n=u;return e|0}function k(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0,k=0,l=0,o=0,h=0,d=0,C=0,g=0;k=f[74]|0;l=f[67]|0;g=k+12|0;f[74]=g;r=w(1)|0;e=f[74]|0;if(!((e|0)==(g|0)?!(I(r)|0):0))C=3;e:do{if((C|0)==3){a:do{switch(r<<16>>16){case 123:{f[74]=e+2;e=w(1)|0;a=f[74]|0;while(1){if(W(e)|0){v(e);e=(f[74]|0)+2|0;f[74]=e}else{q(e)|0;e=f[74]|0}w(1)|0;e=A(a,e)|0;if(e<<16>>16==44){f[74]=(f[74]|0)+2;e=w(1)|0}if(e<<16>>16==125){C=15;break}g=a;a=f[74]|0;if((a|0)==(g|0)){C=12;break}if(a>>>0>(f[75]|0)>>>0){C=14;break}}if((C|0)==12){T();break e}else if((C|0)==14){T();break e}else if((C|0)==15){i[811]=1;f[74]=(f[74]|0)+2;break a}break}case 42:{f[74]=e+2;w(1)|0;g=f[74]|0;A(g,g)|0;break}default:{i[812]=0;switch(r<<16>>16){case 100:{k=e+14|0;f[74]=k;switch((w(1)|0)<<16>>16){case 97:{a=f[74]|0;if((m(a+2|0,80,8)|0)==0?(c=a+10|0,F(s[c>>1]|0)|0):0){f[74]=c;w(0)|0;C=22}break}case 102:{C=22;break}case 99:{a=f[74]|0;if(((m(a+2|0,36,8)|0)==0?(t=a+10|0,g=s[t>>1]|0,V(g)|0|g<<16>>16==123):0)?(f[74]=t,n=w(1)|0,n<<16>>16!=123):0){d=n;C=31}break}default:{}}r:do{if((C|0)==22?(b=f[74]|0,(m(b+2|0,88,14)|0)==0):0){r=b+16|0;a=s[r>>1]|0;if(!(V(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[74]=r;a=w(1)|0;if(a<<16>>16==42){f[74]=(f[74]|0)+2;a=w(1)|0}if(a<<16>>16!=40){d=a;C=31}}}while(0);if((C|0)==31?(o=f[74]|0,q(d)|0,h=f[74]|0,h>>>0>o>>>0):0){O(e,k,o,h);f[74]=(f[74]|0)+-2;break e}O(e,k,0,0);f[74]=e+12;break e}case 97:{f[74]=e+10;w(0)|0;e=f[74]|0;C=35;break}case 102:{C=35;break}case 99:{if((m(e+2|0,36,8)|0)==0?(a=e+10|0,E(s[a>>1]|0)|0):0){f[74]=a;g=w(1)|0;C=f[74]|0;q(g)|0;g=f[74]|0;O(C,g,C,g);f[74]=(f[74]|0)+-2;break e}e=e+4|0;f[74]=e;break}case 108:case 118:break;default:break e}if((C|0)==35){f[74]=e+16;e=w(1)|0;if(e<<16>>16==42){f[74]=(f[74]|0)+2;e=w(1)|0}C=f[74]|0;q(e)|0;g=f[74]|0;O(C,g,C,g);f[74]=(f[74]|0)+-2;break e}f[74]=e+6;i[812]=0;r=w(1)|0;e=f[74]|0;r=(q(r)|0|32)<<16>>16==123;t=f[74]|0;if(r){f[74]=t+2;g=w(1)|0;e=f[74]|0;q(g)|0}r:while(1){a=f[74]|0;if((a|0)==(e|0))break;O(e,a,e,a);a=w(1)|0;if(r)switch(a<<16>>16){case 93:case 125:break e;default:{}}e=f[74]|0;if(a<<16>>16!=44){C=51;break}f[74]=e+2;a=w(1)|0;e=f[74]|0;switch(a<<16>>16){case 91:case 123:{C=51;break r}default:{}}q(a)|0}if((C|0)==51)f[74]=e+-2;if(!r)break e;f[74]=t+-2;break e}}}while(0);g=(w(1)|0)<<16>>16==102;e=f[74]|0;if(g?(m(e+2|0,74,6)|0)==0:0){f[74]=e+8;u(k,w(1)|0,0);e=(l|0)==0?248:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0}}f[74]=e+-2}}while(0);return}function l(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0;b=f[74]|0;c=b+12|0;f[74]=c;e=w(1)|0;t=f[74]|0;e:do{if(e<<16>>16!=46){if(!(e<<16>>16==115&t>>>0>c>>>0)){if(!(e<<16>>16==100&t>>>0>(b+10|0)>>>0)){t=0;n=28;break}if(m(t+2|0,66,8)|0){a=t;e=100;t=0;n=59;break}e=t+10|0;if(!(V(s[e>>1]|0)|0)){a=t;e=100;t=0;n=59;break}f[74]=e;e=w(1)|0;if(e<<16>>16==42){e=42;t=2;n=61;break}f[74]=t;t=0;n=28;break}if((m(t+2|0,56,10)|0)==0?(r=t+12|0,V(s[r>>1]|0)|0):0){f[74]=r;e=w(1)|0;a=f[74]|0;if((a|0)!=(r|0)){if(e<<16>>16!=102){t=1;n=28;break}if(m(a+2|0,74,6)|0){e=102;t=1;n=59;break}if(!(E(s[a+8>>1]|0)|0)){e=102;t=1;n=59;break}}f[74]=t;t=0;n=28}else{a=t;e=115;t=0;n=59}}else{f[74]=t+2;switch((w(1)|0)<<16>>16){case 109:{e=f[74]|0;if(m(e+2|0,50,6)|0)break e;a=f[71]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;d(b,b,e+8|0,2);break e}case 115:{e=f[74]|0;if(m(e+2|0,56,10)|0)break e;a=f[71]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;f[74]=e+12;e=w(1)|0;t=1;n=28;break e}case 100:{e=f[74]|0;if(m(e+2|0,66,8)|0)break e;a=f[71]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;f[74]=e+10;e=w(1)|0;t=2;n=28;break e}default:break e}}}while(0);e:do{if((n|0)==28){if(e<<16>>16==40){r=f[72]|0;a=s[404]|0;c=a&65535;f[r+(c<<3)>>2]=5;e=f[74]|0;s[404]=a+1<<16>>16;f[r+(c<<3)+4>>2]=e;if((s[f[71]>>1]|0)==46)break;f[74]=e+2;a=w(1)|0;d(b,f[74]|0,0,e);if(!t)e=f[65]|0;else{e=f[65]|0;f[e+28>>2]=(t|0)==1?5:7}c=f[73]|0;b=s[403]|0;s[403]=b+1<<16>>16;f[c+((b&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{f[74]=(f[74]|0)+-2;break e}}e=(f[74]|0)+2|0;f[74]=e;switch((w(1)|0)<<16>>16){case 44:{f[74]=(f[74]|0)+2;w(1)|0;c=f[65]|0;f[c+4>>2]=e;b=f[74]|0;f[c+16>>2]=b;i[c+24>>0]=1;f[74]=b+-2;break e}case 41:{s[404]=(s[404]|0)+-1<<16>>16;b=f[65]|0;f[b+4>>2]=e;f[b+12>>2]=(f[74]|0)+2;i[b+24>>0]=1;s[403]=(s[403]|0)+-1<<16>>16;break e}default:{f[74]=(f[74]|0)+-2;break e}}}if(!((t|0)==0&e<<16>>16==123)){switch(e<<16>>16){case 42:case 39:case 34:{n=61;break e}default:{}}a=f[74]|0;n=59;break}e=f[74]|0;if(s[404]|0){f[74]=e+-2;break}while(1){if(e>>>0>=(f[75]|0)>>>0)break;e=w(1)|0;if(!(W(e)|0)){if(e<<16>>16==125){n=49;break}}else v(e);e=(f[74]|0)+2|0;f[74]=e}if((n|0)==49)f[74]=(f[74]|0)+2;c=(w(1)|0)<<16>>16==102;e=f[74]|0;if(c?m(e+2|0,74,6)|0:0){T();break}f[74]=e+8;e=w(1)|0;if(W(e)|0){u(b,e,0);break}else{T();break}}}while(0);if((n|0)==59)if((a|0)==(c|0))f[74]=b+10;else n=61;do{if((n|0)==61){if(!((e<<16>>16==42|(t|0)!=2)&(s[404]|0)==0)){f[74]=(f[74]|0)+-2;break}e=f[75]|0;a=f[74]|0;while(1){if(a>>>0>=e>>>0){n=68;break}r=s[a>>1]|0;if(W(r)|0){n=66;break}n=a+2|0;f[74]=n;a=n}if((n|0)==66){u(b,r,t);break}else if((n|0)==68){T();break}}}while(0);return}function u(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,t=0;i=(f[74]|0)+2|0;switch(a<<16>>16){case 39:{v(39);t=5;break}case 34:{v(34);t=5;break}default:T()}do{if((t|0)==5){d(e,i,f[74]|0,1);if((r|0)>0)f[(f[65]|0)+28>>2]=(r|0)==1?4:6;f[74]=(f[74]|0)+2;a=w(0)|0;r=a<<16>>16==97;if(r){i=f[74]|0;if(m(i+2|0,102,10)|0)t=13}else{i=f[74]|0;if(!(((a<<16>>16==119?(s[i+2>>1]|0)==105:0)?(s[i+4>>1]|0)==116:0)?(s[i+6>>1]|0)==104:0))t=13}if((t|0)==13){f[74]=i+-2;break}f[74]=i+((r?6:4)<<1);if((w(1)|0)<<16>>16!=123){f[74]=i;break}r=f[74]|0;a=r;e:while(1){f[74]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{v(39);f[74]=(f[74]|0)+2;a=w(1)|0;break}case 34:{v(34);f[74]=(f[74]|0)+2;a=w(1)|0;break}default:a=q(a)|0}if(a<<16>>16!=58){t=22;break}f[74]=(f[74]|0)+2;switch((w(1)|0)<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{t=26;break e}}f[74]=(f[74]|0)+2;switch((w(1)|0)<<16>>16){case 125:{t=31;break e}case 44:break;default:{t=30;break e}}f[74]=(f[74]|0)+2;if((w(1)|0)<<16>>16==125){t=31;break}a=f[74]|0}if((t|0)==22){f[74]=i;break}else if((t|0)==26){f[74]=i;break}else if((t|0)==30){f[74]=i;break}else if((t|0)==31){t=f[65]|0;f[t+16>>2]=r;f[t+12>>2]=(f[74]|0)+2;break}}}while(0);return}function o(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=$(e+-4|0,112,2)|0;break e}case 108:{e=$(e+-4|0,116,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=B(e+-6|0,101)|0;break e}case 97:{e=B(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=$(e+-4|0,122,4)|0;break e}case 117:{e=$(e+-4|0,130,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=$(e+-8|0,142,6)|0;break e}case 112:{e=$(e+-8|0,154,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=$(e+-2|0,158,4)|0;break}case 110:{e=e+-2|0;if(B(e,105)|0)e=1;else e=$(e,166,5)|0;break}case 111:{e=B(e+-2|0,100)|0;break}case 114:{e=$(e+-2|0,176,7)|0;break}case 116:{e=$(e+-2|0,190,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=B(e+-4|0,110)|0;break e}case 111:{e=$(e+-4|0,198,3)|0;break e}default:{e=0;break e}}default:e=0}}while(0);return e|0}function h(){var e=0,a=0,r=0,i=0;a=f[75]|0;r=f[74]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e}if((a|0)==6){e=r+4|0;f[74]=e;a=f[72]|0;i=s[404]|0;r=i&65535;f[a+(r<<3)>>2]=4;s[404]=i+1<<16>>16;f[a+(r<<3)+4>>2]=e}else if((a|0)==7){f[74]=e;r=f[72]|0;i=(s[404]|0)+-1<<16>>16;s[404]=i;if((f[r+((i&65535)<<3)>>2]|0)!=3)T()}else if((a|0)==10){f[74]=e;T()}return}function w(e){e=e|0;var a=0,r=0,i=0;r=f[74]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(V(a)|0)break;else break e;else if(F(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{P();break a}case 42:{y(e);break a}default:{a=47;break e}}}while(0);i=f[74]|0;r=i+2|0;f[74]=r}while(i>>>0<(f[75]|0)>>>0);return a|0}function d(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;c=f[69]|0;f[69]=c+36;t=f[65]|0;f[((t|0)==0?244:t+32|0)>>2]=c;f[66]=t;f[65]=c;f[c+8>>2]=e;if(2==(s|0)){e=3;t=r}else{t=1==(s|0);e=t?1:2;t=t?r+2|0:0}f[c+12>>2]=t;f[c+28>>2]=e;f[c>>2]=a;f[c+4>>2]=r;f[c+16>>2]=0;f[c+20>>2]=s;a=1==(s|0);i[c+24>>0]=a&1;f[c+32>>2]=0;if(a|2==(s|0))i[811]=1;return}function v(e){e=e|0;var a=0,r=0,i=0,t=0;t=f[75]|0;a=f[74]|0;while(1){i=a+2|0;if(a>>>0>=t>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r}else a=r}else if(Z(r)|0){a=9;break}else a=i}if((a|0)==9){f[74]=i;T()}else if((a|0)==10)f[74]=i;return}function A(e,a){e=e|0;a=a|0;var r=0,i=0,t=0,c=0;r=f[74]|0;i=s[r>>1]|0;c=(e|0)==(a|0);t=c?0:e;c=c?0:a;if(i<<16>>16==97){f[74]=r+4;r=w(1)|0;e=f[74]|0;if(W(r)|0){v(r);a=(f[74]|0)+2|0;f[74]=a}else{q(r)|0;a=f[74]|0}i=w(1)|0;r=f[74]|0}if((r|0)!=(e|0))O(e,a,t,c);return i|0}function C(){var e=0,a=0,r=0;r=f[75]|0;a=f[74]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e}if((a|0)==6){f[74]=e;T();e=0}else if((a|0)==7){f[74]=e;e=93}return e|0}function g(){var e=0,a=0,r=0;e:while(1){e=f[74]|0;a=e+2|0;f[74]=a;if(e>>>0>=(f[75]|0)>>>0){r=7;break}switch(s[a>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{C()|0;break}case 92:{f[74]=e+4;break}default:{}}}if((r|0)==7)T();return}function p(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=$(e+-2|0,218,4)|0;break}case 121:{e=$(e+-2|0,226,6)|0;break}case 101:{e=$(e+-2|0,238,3)|0;break}default:e=0}return e|0}function y(e){e=e|0;var a=0,r=0,i=0,t=0,c=0;t=(f[74]|0)+2|0;f[74]=t;r=f[75]|0;while(1){a=t+2|0;if(t>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?Z(i)|0:0)break;if(i<<16>>16==42?(s[t+4>>1]|0)==47:0){c=8;break}t=a}if((c|0)==8){f[74]=a;a=t+4|0}f[74]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else{while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else{e=e+1|0;a=a+1|0}}e=(s&255)-(f&255)|0}}while(0);return e|0}function I(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else{switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4}}}while(0);return e|0}function U(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function x(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(I(a)|0)return a<<16>>16!=46|(G(e)|0)|0;else a=0}else a=1}while(0);return a|0}function S(e){e=e|0;var a=0,r=0,i=0,t=0;r=n;n=n+16|0;i=r;f[i>>2]=0;f[68]=e;a=f[3]|0;t=a+(e<<1)|0;e=t+2|0;s[t>>1]=0;f[i>>2]=e;f[69]=e;f[61]=0;f[65]=0;f[63]=0;f[62]=0;f[67]=0;f[64]=0;n=r;return a|0}function O(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;t=f[69]|0;f[69]=t+20;c=f[67]|0;f[((c|0)==0?248:c+16|0)>>2]=t;f[67]=t;f[t>>2]=e;f[t+4>>2]=a;f[t+8>>2]=r;f[t+12>>2]=s;f[t+16>>2]=0;i[811]=1;return}function $(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;i=e+(0-r<<1)|0;s=i+2|0;e=f[3]|0;if(s>>>0>=e>>>0?(m(s,a,r<<1)|0)==0:0)if((s|0)==(e|0))e=1;else e=x(i)|0;else e=0;return e|0}function j(e){e=e|0;switch(s[e>>1]|0){case 107:{e=$(e+-2|0,158,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=$(e+-4|0,130,6)|0;else e=0;break}default:e=0}return e|0}function B(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=E(s[e+-2>>1]|0)|0;else r=0;return r|0}function E(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else{switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(I(e)|0)}}while(0);return e|0}function P(){var e=0,a=0,r=0;e=f[75]|0;r=f[74]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a}}f[74]=a;return}function q(e){e=e|0;while(1){if(V(e)|0)break;if(I(e)|0)break;e=(f[74]|0)+2|0;f[74]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function z(){var e=0;e=f[(f[63]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1}return e|0}function D(e){e=e|0;if(!($(e,204,5)|0)?!($(e,44,3)|0):0)e=$(e,214,2)|0;else e=1;return e|0}function F(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0}return e|0}function G(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function H(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=x(e+-2|0)|0;return e|0}function J(){var e=0;e=f[(f[64]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function K(){var e=0;e=f[(f[63]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function L(){var e=0;e=f[(f[64]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function M(){var e=0;e=f[(f[63]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function N(){var e=0;e=f[(f[63]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Q(){var e=0;e=f[63]|0;e=f[((e|0)==0?244:e+32|0)>>2]|0;f[63]=e;return(e|0)!=0|0}function R(){var e=0;e=f[64]|0;e=f[((e|0)==0?248:e+16|0)>>2]|0;f[64]=e;return(e|0)!=0|0}function T(){i[810]=1;f[70]=(f[74]|0)-(f[3]|0)>>1;f[74]=(f[75]|0)+2;return}function V(e){e=e|0;return(e|128)<<16>>16==160|(e+-9&65535)<5|0}function W(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function X(){return(f[(f[63]|0)+8>>2]|0)-(f[3]|0)>>1|0}function Y(){return(f[(f[64]|0)+4>>2]|0)-(f[3]|0)>>1|0}function Z(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function _(){return(f[f[63]>>2]|0)-(f[3]|0)>>1|0}function ee(){return(f[f[64]>>2]|0)-(f[3]|0)>>1|0}function ae(){return t[(f[63]|0)+24>>0]|0|0}function re(e){e=e|0;f[3]=e;return}function ie(){return f[(f[63]|0)+28>>2]|0}function se(){return(i[811]|0)!=0|0}function fe(){return(i[812]|0)!=0|0}function te(){return f[70]|0}function ce(e){e=e|0;n=e+992+15&-16;return 992}return{su:ce,ai:M,e:te,ee:Y,ele:J,els:L,es:ee,f:fe,id:z,ie:N,ip:ae,is:_,it:ie,ms:se,p:b,re:R,ri:Q,sa:S,se:K,ses:re,ss:X}}("undefined"!=typeof self?self:global,{},a),r=e.su(i-(2<<17))}const h=t.length+1;e.ses(r),e.sa(h-1),s(t,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),c=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,t.charCodeAt(-1===s?a-1:a))),w.push({t:n,n:k,s:a,e:r,ss:f,se:c,d:s,a:i})}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=t.charCodeAt(a),c=i>=0?t.charCodeAt(i):-1;d.push({s:a,e:r,ls:i,le:s,n:34===f||39===f?b(a+1,f):t.slice(a,r),ln:i<0?void 0:34===c||39===c?b(i+1,c):t.slice(i,s)})}return[w,d,!!e.f(),!!e.ms()]}function b(e,a){n=e;let r="",i=n;for(;;){n>=t.length&&o();const e=t.charCodeAt(n);if(e===a)break;92===e?(r+=t.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&o(),++n)}return r+=t.slice(i,n++),r}function k(){let e=t.charCodeAt(++n);switch(++n,e){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=t.charCodeAt(n);let a;123===e?(++n,a=l(t.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===t.charCodeAt(n)&&++n;case 10:return"";case 56:case 57:o();default:if(e>=48&&e<=55){let a=t.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=t.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=t.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else{if(!(s>=48&&s<=57))break;e=s-48}if(e>=16)break;i=s,r=16*r+e}else 95!==i&&0!==a||o(),i=s}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(`Parse error ${c}:${t.slice(0,n).split("\n").length}:${n-t.lastIndexOf("\n",n-1)}`),{idx:n})}
|
node_modules/es-module-lexer/dist/lexer.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"use strict";var ImportType;exports.initSync=exports.init=exports.ImportType=void 0,exports.parse=parse,exports.ImportType=ImportType,function(A){A[A.Static=1]="Static",A[A.Dynamic=2]="Dynamic",A[A.ImportMeta=3]="ImportMeta",A[A.StaticSourcePhase=4]="StaticSourcePhase",A[A.DynamicSourcePhase=5]="DynamicSourcePhase",A[A.StaticDeferPhase=6]="StaticDeferPhase",A[A.DynamicDeferPhase=7]="DynamicDeferPhase"}(ImportType||(exports.ImportType=ImportType={}));const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,w=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;w>0&&C.memory.grow(Math.ceil(w/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const o=[],D=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.it(),g=C.ai(),I=C.id(),w=C.ss(),K=C.se();let D;C.ip()&&(D=k(E.slice(-1===I?A-1:A,-1===I?Q+1:Q))),o.push({n:D,t:B,s:A,e:Q,ss:w,se:K,d:I,a:g})}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),w=I[0],K=B<0?void 0:E.slice(B,g),o=K?K[0]:"";D.push({s:A,e:Q,ls:B,le:g,n:'"'===w||"'"===w?k(I):I,ln:'"'===o||"'"===o?k(K):K})}function k(A){try{return(0,eval)(A)}catch(A){}}return[o,D,!!C.f(),!!C.ms()]}function Q(A,Q){const C=A.length;let B=0;for(;B<C;){const C=A.charCodeAt(B);Q[B++]=(255&C)<<8|C>>>8}}function B(A,Q){const C=A.length;let B=0;for(;B<C;)Q[B]=A.charCodeAt(B++)}let C;const E=()=>{return A="AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAm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ACAAAAAAQAAEA5AAA=","undefined"!=typeof Buffer?Buffer.from(A,"base64"):Uint8Array.from(atob(A),(A=>A.charCodeAt(0)));var A},init=WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({exports:A})=>{C=A}));exports.init=init;const initSync=()=>{if(C)return;const A=new WebAssembly.Module(E());C=new WebAssembly.Instance(A).exports};exports.initSync=initSync;
|
node_modules/es-module-lexer/dist/lexer.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* es-module-lexer 1.7.0 */
|
| 2 |
+
export var ImportType;!function(A){A[A.Static=1]="Static",A[A.Dynamic=2]="Dynamic",A[A.ImportMeta=3]="ImportMeta",A[A.StaticSourcePhase=4]="StaticSourcePhase",A[A.DynamicSourcePhase=5]="DynamicSourcePhase",A[A.StaticDeferPhase=6]="StaticDeferPhase",A[A.DynamicDeferPhase=7]="DynamicDeferPhase"}(ImportType||(ImportType={}));const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];export function parse(E,g="@"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,w=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;w>0&&C.memory.grow(Math.ceil(w/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const o=[],D=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.it(),g=C.ai(),I=C.id(),w=C.ss(),K=C.se();let D;C.ip()&&(D=k(E.slice(-1===I?A-1:A,-1===I?Q+1:Q))),o.push({n:D,t:B,s:A,e:Q,ss:w,se:K,d:I,a:g})}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),w=I[0],K=B<0?void 0:E.slice(B,g),o=K?K[0]:"";D.push({s:A,e:Q,ls:B,le:g,n:'"'===w||"'"===w?k(I):I,ln:'"'===o||"'"===o?k(K):K})}function k(A){try{return(0,eval)(A)}catch(A){}}return[o,D,!!C.f(),!!C.ms()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++)}let C;const E=()=>{return A="AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKzkQwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwCUEAQQA2AugJQQBBADYC5AlBAEEANgL4CUEAQQA2AuwJIAEL0wEBA39BACgC8AkhBEEAQQAoAogKIgU2AvAJQQAgBDYC9AlBACAFQSRqNgKICiAEQSBqQeAJIAQbIAU2AgBBACgC1AkhBEEAKALQCSEGIAUgATYCACAFIAA2AgggBSACIAJBAmpBACAGIANGIgAbIAQgA0YiBBs2AgwgBSADNgIUIAVBADYCECAFIAI2AgQgBUEANgIgIAVBA0EBQQIgABsgBBs2AhwgBUEAKALQCSADRiICOgAYAkACQCACDQBBACgC1AkgA0cNAQtBAEEBOgCMCgsLXgEBf0EAKAL4CSIEQRBqQeQJIAQbQQAoAogKIgQ2AgBBACAENgL4CUEAIARBFGo2AogKQQBBAToAjAogBEEANgIQIAQgAzYCDCAEIAI2A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ACyACIQAgA0F2ag4EAgEBAgELIABBBGohAAwACwtBACACNgKwChAlQQAPC0EAIAI2ArAKQd0AC0kBA39BACEDAkAgAkUNAAJAA0AgAC0AACIEIAEtAAAiBUcNASABQQFqIQEgAEEBaiEAIAJBf2oiAg0ADAILCyAEIAVrIQMLIAMLC+wBAgBBgAgLzgEAAHgAcABvAHIAdABtAHAAbwByAHQAZgBvAHIAZQB0AGEAbwB1AHIAYwBlAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABB0AkLEAEAAAACAAAAAAQAAEA5AAA=","undefined"!=typeof Buffer?Buffer.from(A,"base64"):Uint8Array.from(atob(A),(A=>A.charCodeAt(0)));var A};export const init=WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({exports:A})=>{C=A}));export const initSync=()=>{if(C)return;const A=new WebAssembly.Module(E());C=new WebAssembly.Instance(A).exports};
|
node_modules/es-module-lexer/lexer.js
ADDED
|
@@ -0,0 +1,925 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
let source, pos, end,
|
| 2 |
+
openTokenDepth,
|
| 3 |
+
lastTokenPos,
|
| 4 |
+
openTokenPosStack,
|
| 5 |
+
openClassPosStack,
|
| 6 |
+
curDynamicImport,
|
| 7 |
+
templateStackDepth,
|
| 8 |
+
facade,
|
| 9 |
+
lastSlashWasDivision,
|
| 10 |
+
nextBraceIsClass,
|
| 11 |
+
templateDepth,
|
| 12 |
+
templateStack,
|
| 13 |
+
imports,
|
| 14 |
+
exports,
|
| 15 |
+
name;
|
| 16 |
+
|
| 17 |
+
function addImport (ss, s, e, d) {
|
| 18 |
+
const impt = { ss, se: d === -2 ? e : d === -1 ? e + 1 : 0, s, e, d, a: -1, n: undefined };
|
| 19 |
+
imports.push(impt);
|
| 20 |
+
return impt;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function addExport (s, e, ls, le) {
|
| 24 |
+
exports.push({
|
| 25 |
+
s,
|
| 26 |
+
e,
|
| 27 |
+
ls,
|
| 28 |
+
le,
|
| 29 |
+
n: s[0] === '"' ? readString(s, '"') : s[0] === "'" ? readString(s, "'") : source.slice(s, e),
|
| 30 |
+
ln: ls[0] === '"' ? readString(ls, '"') : ls[0] === "'" ? readString(ls, "'") : source.slice(ls, le)
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function readName (impt) {
|
| 35 |
+
let { d, s } = impt;
|
| 36 |
+
if (d !== -1)
|
| 37 |
+
s++;
|
| 38 |
+
impt.n = readString(s, source.charCodeAt(s - 1));
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
// Note: parsing is based on the _assumption_ that the source is already valid
|
| 42 |
+
export function parse (_source, _name) {
|
| 43 |
+
openTokenDepth = 0;
|
| 44 |
+
curDynamicImport = null;
|
| 45 |
+
templateDepth = -1;
|
| 46 |
+
lastTokenPos = -1;
|
| 47 |
+
lastSlashWasDivision = false;
|
| 48 |
+
templateStack = Array(1024);
|
| 49 |
+
templateStackDepth = 0;
|
| 50 |
+
openTokenPosStack = Array(1024);
|
| 51 |
+
openClassPosStack = Array(1024);
|
| 52 |
+
nextBraceIsClass = false;
|
| 53 |
+
facade = true;
|
| 54 |
+
name = _name || '@';
|
| 55 |
+
|
| 56 |
+
imports = [];
|
| 57 |
+
exports = [];
|
| 58 |
+
|
| 59 |
+
source = _source;
|
| 60 |
+
pos = -1;
|
| 61 |
+
end = source.length - 1;
|
| 62 |
+
let ch = 0;
|
| 63 |
+
|
| 64 |
+
// start with a pure "module-only" parser
|
| 65 |
+
m: while (pos++ < end) {
|
| 66 |
+
ch = source.charCodeAt(pos);
|
| 67 |
+
|
| 68 |
+
if (ch === 32 || ch < 14 && ch > 8)
|
| 69 |
+
continue;
|
| 70 |
+
|
| 71 |
+
switch (ch) {
|
| 72 |
+
case 101/*e*/:
|
| 73 |
+
if (openTokenDepth === 0 && keywordStart(pos) && source.startsWith('xport', pos + 1)) {
|
| 74 |
+
tryParseExportStatement();
|
| 75 |
+
// export might have been a non-pure declaration
|
| 76 |
+
if (!facade) {
|
| 77 |
+
lastTokenPos = pos;
|
| 78 |
+
break m;
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
break;
|
| 82 |
+
case 105/*i*/:
|
| 83 |
+
if (keywordStart(pos) && source.startsWith('mport', pos + 1))
|
| 84 |
+
tryParseImportStatement();
|
| 85 |
+
break;
|
| 86 |
+
case 59/*;*/:
|
| 87 |
+
break;
|
| 88 |
+
case 47/*/*/: {
|
| 89 |
+
const next_ch = source.charCodeAt(pos + 1);
|
| 90 |
+
if (next_ch === 47/*/*/) {
|
| 91 |
+
lineComment();
|
| 92 |
+
// dont update lastToken
|
| 93 |
+
continue;
|
| 94 |
+
}
|
| 95 |
+
else if (next_ch === 42/***/) {
|
| 96 |
+
blockComment(true);
|
| 97 |
+
// dont update lastToken
|
| 98 |
+
continue;
|
| 99 |
+
}
|
| 100 |
+
// fallthrough
|
| 101 |
+
}
|
| 102 |
+
default:
|
| 103 |
+
// as soon as we hit a non-module token, we go to main parser
|
| 104 |
+
facade = false;
|
| 105 |
+
pos--;
|
| 106 |
+
break m;
|
| 107 |
+
}
|
| 108 |
+
lastTokenPos = pos;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
while (pos++ < end) {
|
| 112 |
+
ch = source.charCodeAt(pos);
|
| 113 |
+
|
| 114 |
+
if (ch === 32 || ch < 14 && ch > 8)
|
| 115 |
+
continue;
|
| 116 |
+
|
| 117 |
+
switch (ch) {
|
| 118 |
+
case 101/*e*/:
|
| 119 |
+
if (openTokenDepth === 0 && keywordStart(pos) && source.startsWith('xport', pos + 1))
|
| 120 |
+
tryParseExportStatement();
|
| 121 |
+
break;
|
| 122 |
+
case 105/*i*/:
|
| 123 |
+
if (keywordStart(pos) && source.startsWith('mport', pos + 1))
|
| 124 |
+
tryParseImportStatement();
|
| 125 |
+
break;
|
| 126 |
+
case 99/*c*/:
|
| 127 |
+
if (keywordStart(pos) && source.startsWith('lass', pos + 1) && isBrOrWs(source.charCodeAt(pos + 5)))
|
| 128 |
+
nextBraceIsClass = true;
|
| 129 |
+
break;
|
| 130 |
+
case 40/*(*/:
|
| 131 |
+
openTokenPosStack[openTokenDepth++] = lastTokenPos;
|
| 132 |
+
break;
|
| 133 |
+
case 41/*)*/:
|
| 134 |
+
if (openTokenDepth === 0)
|
| 135 |
+
syntaxError();
|
| 136 |
+
openTokenDepth--;
|
| 137 |
+
if (curDynamicImport && curDynamicImport.d === openTokenPosStack[openTokenDepth]) {
|
| 138 |
+
if (curDynamicImport.e === 0)
|
| 139 |
+
curDynamicImport.e = pos;
|
| 140 |
+
curDynamicImport.se = pos;
|
| 141 |
+
curDynamicImport = null;
|
| 142 |
+
}
|
| 143 |
+
break;
|
| 144 |
+
case 123/*{*/:
|
| 145 |
+
// dynamic import followed by { is not a dynamic import (so remove)
|
| 146 |
+
// this is a sneaky way to get around { import () {} } v { import () }
|
| 147 |
+
// block / object ambiguity without a parser (assuming source is valid)
|
| 148 |
+
if (source.charCodeAt(lastTokenPos) === 41/*)*/ && imports.length && imports[imports.length - 1].e === lastTokenPos) {
|
| 149 |
+
imports.pop();
|
| 150 |
+
}
|
| 151 |
+
openClassPosStack[openTokenDepth] = nextBraceIsClass;
|
| 152 |
+
nextBraceIsClass = false;
|
| 153 |
+
openTokenPosStack[openTokenDepth++] = lastTokenPos;
|
| 154 |
+
break;
|
| 155 |
+
case 125/*}*/:
|
| 156 |
+
if (openTokenDepth === 0)
|
| 157 |
+
syntaxError();
|
| 158 |
+
if (openTokenDepth-- === templateDepth) {
|
| 159 |
+
templateDepth = templateStack[--templateStackDepth];
|
| 160 |
+
templateString();
|
| 161 |
+
}
|
| 162 |
+
else {
|
| 163 |
+
if (templateDepth !== -1 && openTokenDepth < templateDepth)
|
| 164 |
+
syntaxError();
|
| 165 |
+
}
|
| 166 |
+
break;
|
| 167 |
+
case 39/*'*/:
|
| 168 |
+
case 34/*"*/:
|
| 169 |
+
stringLiteral(ch);
|
| 170 |
+
break;
|
| 171 |
+
case 47/*/*/: {
|
| 172 |
+
const next_ch = source.charCodeAt(pos + 1);
|
| 173 |
+
if (next_ch === 47/*/*/) {
|
| 174 |
+
lineComment();
|
| 175 |
+
// dont update lastToken
|
| 176 |
+
continue;
|
| 177 |
+
}
|
| 178 |
+
else if (next_ch === 42/***/) {
|
| 179 |
+
blockComment(true);
|
| 180 |
+
// dont update lastToken
|
| 181 |
+
continue;
|
| 182 |
+
}
|
| 183 |
+
else {
|
| 184 |
+
// Division / regex ambiguity handling based on checking backtrack analysis of:
|
| 185 |
+
// - what token came previously (lastToken)
|
| 186 |
+
// - if a closing brace or paren, what token came before the corresponding
|
| 187 |
+
// opening brace or paren (lastOpenTokenIndex)
|
| 188 |
+
const lastToken = source.charCodeAt(lastTokenPos);
|
| 189 |
+
const lastExport = exports[exports.length - 1];
|
| 190 |
+
if (isExpressionPunctuator(lastToken) &&
|
| 191 |
+
!(lastToken === 46/*.*/ && (source.charCodeAt(lastTokenPos - 1) >= 48/*0*/ && source.charCodeAt(lastTokenPos - 1) <= 57/*9*/)) &&
|
| 192 |
+
!(lastToken === 43/*+*/ && source.charCodeAt(lastTokenPos - 1) === 43/*+*/) && !(lastToken === 45/*-*/ && source.charCodeAt(lastTokenPos - 1) === 45/*-*/) ||
|
| 193 |
+
lastToken === 41/*)*/ && isParenKeyword(openTokenPosStack[openTokenDepth]) ||
|
| 194 |
+
lastToken === 125/*}*/ && (isExpressionTerminator(openTokenPosStack[openTokenDepth]) || openClassPosStack[openTokenDepth]) ||
|
| 195 |
+
lastToken === 47/*/*/ && lastSlashWasDivision ||
|
| 196 |
+
isExpressionKeyword(lastTokenPos) ||
|
| 197 |
+
!lastToken) {
|
| 198 |
+
regularExpression();
|
| 199 |
+
lastSlashWasDivision = false;
|
| 200 |
+
}
|
| 201 |
+
else if (lastExport && lastTokenPos >= lastExport.s && lastTokenPos <= lastExport.e) {
|
| 202 |
+
// export default /some-regexp/
|
| 203 |
+
regularExpression();
|
| 204 |
+
lastSlashWasDivision = false;
|
| 205 |
+
}
|
| 206 |
+
else {
|
| 207 |
+
lastSlashWasDivision = true;
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
break;
|
| 211 |
+
}
|
| 212 |
+
case 96/*`*/:
|
| 213 |
+
templateString();
|
| 214 |
+
break;
|
| 215 |
+
}
|
| 216 |
+
lastTokenPos = pos;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
if (templateDepth !== -1 || openTokenDepth)
|
| 220 |
+
syntaxError();
|
| 221 |
+
|
| 222 |
+
return [imports, exports, facade];
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
function tryParseImportStatement () {
|
| 226 |
+
const startPos = pos;
|
| 227 |
+
|
| 228 |
+
pos += 6;
|
| 229 |
+
|
| 230 |
+
let ch = commentWhitespace(true);
|
| 231 |
+
|
| 232 |
+
switch (ch) {
|
| 233 |
+
// dynamic import
|
| 234 |
+
case 40/*(*/:
|
| 235 |
+
openTokenPosStack[openTokenDepth++] = startPos;
|
| 236 |
+
if (source.charCodeAt(lastTokenPos) === 46/*.*/)
|
| 237 |
+
return;
|
| 238 |
+
// dynamic import indicated by positive d
|
| 239 |
+
const impt = addImport(startPos, pos + 1, 0, startPos);
|
| 240 |
+
curDynamicImport = impt;
|
| 241 |
+
// try parse a string, to record a safe dynamic import string
|
| 242 |
+
pos++;
|
| 243 |
+
ch = commentWhitespace(true);
|
| 244 |
+
if (ch === 39/*'*/ || ch === 34/*"*/) {
|
| 245 |
+
stringLiteral(ch);
|
| 246 |
+
}
|
| 247 |
+
else {
|
| 248 |
+
pos--;
|
| 249 |
+
return;
|
| 250 |
+
}
|
| 251 |
+
pos++;
|
| 252 |
+
ch = commentWhitespace(true);
|
| 253 |
+
if (ch === 44/*,*/) {
|
| 254 |
+
impt.e = pos;
|
| 255 |
+
pos++;
|
| 256 |
+
ch = commentWhitespace(true);
|
| 257 |
+
impt.a = pos;
|
| 258 |
+
readName(impt);
|
| 259 |
+
pos--;
|
| 260 |
+
}
|
| 261 |
+
else if (ch === 41/*)*/) {
|
| 262 |
+
openTokenDepth--;
|
| 263 |
+
impt.e = pos;
|
| 264 |
+
impt.se = pos;
|
| 265 |
+
readName(impt);
|
| 266 |
+
}
|
| 267 |
+
else {
|
| 268 |
+
pos--;
|
| 269 |
+
}
|
| 270 |
+
return;
|
| 271 |
+
// import.meta
|
| 272 |
+
case 46/*.*/:
|
| 273 |
+
pos++;
|
| 274 |
+
ch = commentWhitespace(true);
|
| 275 |
+
// import.meta indicated by d === -2
|
| 276 |
+
if (ch === 109/*m*/ && source.startsWith('eta', pos + 1) && source.charCodeAt(lastTokenPos) !== 46/*.*/)
|
| 277 |
+
addImport(startPos, startPos, pos + 4, -2);
|
| 278 |
+
return;
|
| 279 |
+
|
| 280 |
+
default:
|
| 281 |
+
// no space after "import" -> not an import keyword
|
| 282 |
+
if (pos === startPos + 6)
|
| 283 |
+
break;
|
| 284 |
+
case 34/*"*/:
|
| 285 |
+
case 39/*'*/:
|
| 286 |
+
case 123/*{*/:
|
| 287 |
+
case 42/***/:
|
| 288 |
+
// import statement only permitted at base-level
|
| 289 |
+
if (openTokenDepth !== 0) {
|
| 290 |
+
pos--;
|
| 291 |
+
return;
|
| 292 |
+
}
|
| 293 |
+
while (pos < end) {
|
| 294 |
+
ch = source.charCodeAt(pos);
|
| 295 |
+
if (ch === 39/*'*/ || ch === 34/*"*/) {
|
| 296 |
+
readImportString(startPos, ch);
|
| 297 |
+
return;
|
| 298 |
+
}
|
| 299 |
+
pos++;
|
| 300 |
+
}
|
| 301 |
+
syntaxError();
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
function tryParseExportStatement () {
|
| 306 |
+
const sStartPos = pos;
|
| 307 |
+
const prevExport = exports.length;
|
| 308 |
+
|
| 309 |
+
pos += 6;
|
| 310 |
+
|
| 311 |
+
const curPos = pos;
|
| 312 |
+
|
| 313 |
+
let ch = commentWhitespace(true);
|
| 314 |
+
|
| 315 |
+
if (pos === curPos && !isPunctuator(ch))
|
| 316 |
+
return;
|
| 317 |
+
|
| 318 |
+
switch (ch) {
|
| 319 |
+
// export default ...
|
| 320 |
+
case 100/*d*/:
|
| 321 |
+
addExport(pos, pos + 7, -1, -1);
|
| 322 |
+
return;
|
| 323 |
+
|
| 324 |
+
// export async? function*? name () {
|
| 325 |
+
case 97/*a*/:
|
| 326 |
+
pos += 5;
|
| 327 |
+
commentWhitespace(true);
|
| 328 |
+
// fallthrough
|
| 329 |
+
case 102/*f*/:
|
| 330 |
+
pos += 8;
|
| 331 |
+
ch = commentWhitespace(true);
|
| 332 |
+
if (ch === 42/***/) {
|
| 333 |
+
pos++;
|
| 334 |
+
ch = commentWhitespace(true);
|
| 335 |
+
}
|
| 336 |
+
const startPos = pos;
|
| 337 |
+
ch = readToWsOrPunctuator(ch);
|
| 338 |
+
addExport(startPos, pos, startPos, pos);
|
| 339 |
+
pos--;
|
| 340 |
+
return;
|
| 341 |
+
|
| 342 |
+
// export class name ...
|
| 343 |
+
case 99/*c*/:
|
| 344 |
+
if (source.startsWith('lass', pos + 1) && isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos + 5))) {
|
| 345 |
+
pos += 5;
|
| 346 |
+
ch = commentWhitespace(true);
|
| 347 |
+
const startPos = pos;
|
| 348 |
+
ch = readToWsOrPunctuator(ch);
|
| 349 |
+
addExport(startPos, pos, startPos, pos);
|
| 350 |
+
pos--;
|
| 351 |
+
return;
|
| 352 |
+
}
|
| 353 |
+
pos += 2;
|
| 354 |
+
// fallthrough
|
| 355 |
+
|
| 356 |
+
// export var/let/const name = ...(, name = ...)+
|
| 357 |
+
case 118/*v*/:
|
| 358 |
+
case 109/*l*/:
|
| 359 |
+
// destructured initializations not currently supported (skipped for { or [)
|
| 360 |
+
// also, lexing names after variable equals is skipped (export var p = function () { ... }, q = 5 skips "q")
|
| 361 |
+
pos += 2;
|
| 362 |
+
facade = false;
|
| 363 |
+
do {
|
| 364 |
+
pos++;
|
| 365 |
+
ch = commentWhitespace(true);
|
| 366 |
+
const startPos = pos;
|
| 367 |
+
ch = readToWsOrPunctuator(ch);
|
| 368 |
+
// dont yet handle [ { destructurings
|
| 369 |
+
if (ch === 123/*{*/ || ch === 91/*[*/) {
|
| 370 |
+
pos--;
|
| 371 |
+
return;
|
| 372 |
+
}
|
| 373 |
+
if (pos === startPos)
|
| 374 |
+
return;
|
| 375 |
+
addExport(startPos, pos, startPos, pos);
|
| 376 |
+
ch = commentWhitespace(true);
|
| 377 |
+
if (ch === 61/*=*/) {
|
| 378 |
+
pos--;
|
| 379 |
+
return;
|
| 380 |
+
}
|
| 381 |
+
} while (ch === 44/*,*/);
|
| 382 |
+
pos--;
|
| 383 |
+
return;
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
// export {...}
|
| 387 |
+
case 123/*{*/:
|
| 388 |
+
pos++;
|
| 389 |
+
ch = commentWhitespace(true);
|
| 390 |
+
while (true) {
|
| 391 |
+
const startPos = pos;
|
| 392 |
+
readToWsOrPunctuator(ch);
|
| 393 |
+
const endPos = pos;
|
| 394 |
+
commentWhitespace(true);
|
| 395 |
+
ch = readExportAs(startPos, endPos);
|
| 396 |
+
// ,
|
| 397 |
+
if (ch === 44/*,*/) {
|
| 398 |
+
pos++;
|
| 399 |
+
ch = commentWhitespace(true);
|
| 400 |
+
}
|
| 401 |
+
if (ch === 125/*}*/)
|
| 402 |
+
break;
|
| 403 |
+
if (pos === startPos)
|
| 404 |
+
return syntaxError();
|
| 405 |
+
if (pos > end)
|
| 406 |
+
return syntaxError();
|
| 407 |
+
}
|
| 408 |
+
pos++;
|
| 409 |
+
ch = commentWhitespace(true);
|
| 410 |
+
break;
|
| 411 |
+
|
| 412 |
+
// export *
|
| 413 |
+
// export * as X
|
| 414 |
+
case 42/***/:
|
| 415 |
+
pos++;
|
| 416 |
+
commentWhitespace(true);
|
| 417 |
+
ch = readExportAs(pos, pos);
|
| 418 |
+
ch = commentWhitespace(true);
|
| 419 |
+
break;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
// from ...
|
| 423 |
+
if (ch === 102/*f*/ && source.startsWith('rom', pos + 1)) {
|
| 424 |
+
pos += 4;
|
| 425 |
+
readImportString(sStartPos, commentWhitespace(true));
|
| 426 |
+
|
| 427 |
+
// There were no local names.
|
| 428 |
+
for (let i = prevExport; i < exports.length; ++i) {
|
| 429 |
+
exports[i].ls = exports[i].le = -1;
|
| 430 |
+
exports[i].ln = undefined;
|
| 431 |
+
}
|
| 432 |
+
}
|
| 433 |
+
else {
|
| 434 |
+
pos--;
|
| 435 |
+
}
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
/*
|
| 439 |
+
* Ported from Acorn
|
| 440 |
+
*
|
| 441 |
+
* MIT License
|
| 442 |
+
|
| 443 |
+
* Copyright (C) 2012-2020 by various contributors (see AUTHORS)
|
| 444 |
+
|
| 445 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 446 |
+
* of this software and associated documentation files (the "Software"), to deal
|
| 447 |
+
* in the Software without restriction, including without limitation the rights
|
| 448 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 449 |
+
* copies of the Software, and to permit persons to whom the Software is
|
| 450 |
+
* furnished to do so, subject to the following conditions:
|
| 451 |
+
|
| 452 |
+
* The above copyright notice and this permission notice shall be included in
|
| 453 |
+
* all copies or substantial portions of the Software.
|
| 454 |
+
|
| 455 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 456 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 457 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 458 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 459 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 460 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 461 |
+
* THE SOFTWARE.
|
| 462 |
+
*/
|
| 463 |
+
let acornPos;
|
| 464 |
+
function readString (start, quote) {
|
| 465 |
+
acornPos = start;
|
| 466 |
+
let out = '', chunkStart = acornPos;
|
| 467 |
+
for (;;) {
|
| 468 |
+
if (acornPos >= source.length) syntaxError();
|
| 469 |
+
const ch = source.charCodeAt(acornPos);
|
| 470 |
+
if (ch === quote) break;
|
| 471 |
+
if (ch === 92) { // '\'
|
| 472 |
+
out += source.slice(chunkStart, acornPos);
|
| 473 |
+
out += readEscapedChar();
|
| 474 |
+
chunkStart = acornPos;
|
| 475 |
+
}
|
| 476 |
+
else if (ch === 0x2028 || ch === 0x2029) {
|
| 477 |
+
++acornPos;
|
| 478 |
+
}
|
| 479 |
+
else {
|
| 480 |
+
if (isBr(ch)) syntaxError();
|
| 481 |
+
++acornPos;
|
| 482 |
+
}
|
| 483 |
+
}
|
| 484 |
+
out += source.slice(chunkStart, acornPos++);
|
| 485 |
+
return out;
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
// Used to read escaped characters
|
| 489 |
+
|
| 490 |
+
function readEscapedChar () {
|
| 491 |
+
let ch = source.charCodeAt(++acornPos);
|
| 492 |
+
++acornPos;
|
| 493 |
+
switch (ch) {
|
| 494 |
+
case 110: return '\n'; // 'n' -> '\n'
|
| 495 |
+
case 114: return '\r'; // 'r' -> '\r'
|
| 496 |
+
case 120: return String.fromCharCode(readHexChar(2)); // 'x'
|
| 497 |
+
case 117: return readCodePointToString(); // 'u'
|
| 498 |
+
case 116: return '\t'; // 't' -> '\t'
|
| 499 |
+
case 98: return '\b'; // 'b' -> '\b'
|
| 500 |
+
case 118: return '\u000b'; // 'v' -> '\u000b'
|
| 501 |
+
case 102: return '\f'; // 'f' -> '\f'
|
| 502 |
+
case 13: if (source.charCodeAt(acornPos) === 10) ++acornPos; // '\r\n'
|
| 503 |
+
case 10: // ' \n'
|
| 504 |
+
return '';
|
| 505 |
+
case 56:
|
| 506 |
+
case 57:
|
| 507 |
+
syntaxError();
|
| 508 |
+
default:
|
| 509 |
+
if (ch >= 48 && ch <= 55) {
|
| 510 |
+
let octalStr = source.substr(acornPos - 1, 3).match(/^[0-7]+/)[0];
|
| 511 |
+
let octal = parseInt(octalStr, 8);
|
| 512 |
+
if (octal > 255) {
|
| 513 |
+
octalStr = octalStr.slice(0, -1);
|
| 514 |
+
octal = parseInt(octalStr, 8);
|
| 515 |
+
}
|
| 516 |
+
acornPos += octalStr.length - 1;
|
| 517 |
+
ch = source.charCodeAt(acornPos);
|
| 518 |
+
if (octalStr !== '0' || ch === 56 || ch === 57)
|
| 519 |
+
syntaxError();
|
| 520 |
+
return String.fromCharCode(octal);
|
| 521 |
+
}
|
| 522 |
+
if (isBr(ch)) {
|
| 523 |
+
// Unicode new line characters after \ get removed from output in both
|
| 524 |
+
// template literals and strings
|
| 525 |
+
return '';
|
| 526 |
+
}
|
| 527 |
+
return String.fromCharCode(ch);
|
| 528 |
+
}
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
// Used to read character escape sequences ('\x', '\u', '\U').
|
| 532 |
+
|
| 533 |
+
function readHexChar (len) {
|
| 534 |
+
const start = acornPos;
|
| 535 |
+
let total = 0, lastCode = 0;
|
| 536 |
+
for (let i = 0; i < len; ++i, ++acornPos) {
|
| 537 |
+
let code = source.charCodeAt(acornPos), val;
|
| 538 |
+
|
| 539 |
+
if (code === 95) {
|
| 540 |
+
if (lastCode === 95 || i === 0) syntaxError();
|
| 541 |
+
lastCode = code;
|
| 542 |
+
continue;
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
if (code >= 97) val = code - 97 + 10; // a
|
| 546 |
+
else if (code >= 65) val = code - 65 + 10; // A
|
| 547 |
+
else if (code >= 48 && code <= 57) val = code - 48; // 0-9
|
| 548 |
+
else break;
|
| 549 |
+
if (val >= 16) break;
|
| 550 |
+
lastCode = code;
|
| 551 |
+
total = total * 16 + val;
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
if (lastCode === 95 || acornPos - start !== len) syntaxError();
|
| 555 |
+
|
| 556 |
+
return total;
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
// Read a string value, interpreting backslash-escapes.
|
| 560 |
+
|
| 561 |
+
function readCodePointToString () {
|
| 562 |
+
const ch = source.charCodeAt(acornPos);
|
| 563 |
+
let code;
|
| 564 |
+
if (ch === 123) { // '{'
|
| 565 |
+
++acornPos;
|
| 566 |
+
code = readHexChar(source.indexOf('}', acornPos) - acornPos);
|
| 567 |
+
++acornPos;
|
| 568 |
+
if (code > 0x10FFFF) syntaxError();
|
| 569 |
+
} else {
|
| 570 |
+
code = readHexChar(4);
|
| 571 |
+
}
|
| 572 |
+
// UTF-16 Decoding
|
| 573 |
+
if (code <= 0xFFFF) return String.fromCharCode(code);
|
| 574 |
+
code -= 0x10000;
|
| 575 |
+
return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
/*
|
| 579 |
+
* </ Acorn Port>
|
| 580 |
+
*/
|
| 581 |
+
|
| 582 |
+
function readExportAs (startPos, endPos) {
|
| 583 |
+
let ch = source.charCodeAt(pos);
|
| 584 |
+
let ls = startPos, le = endPos;
|
| 585 |
+
if (ch === 97 /*a*/) {
|
| 586 |
+
pos += 2;
|
| 587 |
+
ch = commentWhitespace(true);
|
| 588 |
+
startPos = pos;
|
| 589 |
+
readToWsOrPunctuator(ch);
|
| 590 |
+
endPos = pos;
|
| 591 |
+
ch = commentWhitespace(true);
|
| 592 |
+
}
|
| 593 |
+
if (pos !== startPos)
|
| 594 |
+
addExport(startPos, endPos, ls, le);
|
| 595 |
+
return ch;
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
function readImportString (ss, ch) {
|
| 599 |
+
const startPos = pos + 1;
|
| 600 |
+
if (ch === 39/*'*/ || ch === 34/*"*/) {
|
| 601 |
+
stringLiteral(ch);
|
| 602 |
+
}
|
| 603 |
+
else {
|
| 604 |
+
syntaxError();
|
| 605 |
+
return;
|
| 606 |
+
}
|
| 607 |
+
const impt = addImport(ss, startPos, pos, -1);
|
| 608 |
+
readName(impt);
|
| 609 |
+
pos++;
|
| 610 |
+
ch = commentWhitespace(false);
|
| 611 |
+
if (ch !== 97/*a*/ || !source.startsWith('ssert', pos + 1)) {
|
| 612 |
+
pos--;
|
| 613 |
+
return;
|
| 614 |
+
}
|
| 615 |
+
const assertIndex = pos;
|
| 616 |
+
|
| 617 |
+
pos += 6;
|
| 618 |
+
ch = commentWhitespace(true);
|
| 619 |
+
if (ch !== 123/*{*/) {
|
| 620 |
+
pos = assertIndex;
|
| 621 |
+
return;
|
| 622 |
+
}
|
| 623 |
+
const assertStart = pos;
|
| 624 |
+
do {
|
| 625 |
+
pos++;
|
| 626 |
+
ch = commentWhitespace(true);
|
| 627 |
+
if (ch === 39/*'*/ || ch === 34/*"*/) {
|
| 628 |
+
stringLiteral(ch);
|
| 629 |
+
pos++;
|
| 630 |
+
ch = commentWhitespace(true);
|
| 631 |
+
}
|
| 632 |
+
else {
|
| 633 |
+
ch = readToWsOrPunctuator(ch);
|
| 634 |
+
}
|
| 635 |
+
if (ch !== 58/*:*/) {
|
| 636 |
+
pos = assertIndex;
|
| 637 |
+
return;
|
| 638 |
+
}
|
| 639 |
+
pos++;
|
| 640 |
+
ch = commentWhitespace(true);
|
| 641 |
+
if (ch === 39/*'*/ || ch === 34/*"*/) {
|
| 642 |
+
stringLiteral(ch);
|
| 643 |
+
}
|
| 644 |
+
else {
|
| 645 |
+
pos = assertIndex;
|
| 646 |
+
return;
|
| 647 |
+
}
|
| 648 |
+
pos++;
|
| 649 |
+
ch = commentWhitespace(true);
|
| 650 |
+
if (ch === 44/*,*/) {
|
| 651 |
+
pos++;
|
| 652 |
+
ch = commentWhitespace(true);
|
| 653 |
+
if (ch === 125/*}*/)
|
| 654 |
+
break;
|
| 655 |
+
continue;
|
| 656 |
+
}
|
| 657 |
+
if (ch === 125/*}*/)
|
| 658 |
+
break;
|
| 659 |
+
pos = assertIndex;
|
| 660 |
+
return;
|
| 661 |
+
} while (true);
|
| 662 |
+
impt.a = assertStart;
|
| 663 |
+
impt.se = pos + 1;
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
function commentWhitespace (br) {
|
| 667 |
+
let ch;
|
| 668 |
+
do {
|
| 669 |
+
ch = source.charCodeAt(pos);
|
| 670 |
+
if (ch === 47/*/*/) {
|
| 671 |
+
const next_ch = source.charCodeAt(pos + 1);
|
| 672 |
+
if (next_ch === 47/*/*/)
|
| 673 |
+
lineComment();
|
| 674 |
+
else if (next_ch === 42/***/)
|
| 675 |
+
blockComment(br);
|
| 676 |
+
else
|
| 677 |
+
return ch;
|
| 678 |
+
}
|
| 679 |
+
else if (br ? !isBrOrWs(ch): !isWsNotBr(ch)) {
|
| 680 |
+
return ch;
|
| 681 |
+
}
|
| 682 |
+
} while (pos++ < end);
|
| 683 |
+
return ch;
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
function templateString () {
|
| 687 |
+
while (pos++ < end) {
|
| 688 |
+
const ch = source.charCodeAt(pos);
|
| 689 |
+
if (ch === 36/*$*/ && source.charCodeAt(pos + 1) === 123/*{*/) {
|
| 690 |
+
pos++;
|
| 691 |
+
templateStack[templateStackDepth++] = templateDepth;
|
| 692 |
+
templateDepth = ++openTokenDepth;
|
| 693 |
+
return;
|
| 694 |
+
}
|
| 695 |
+
if (ch === 96/*`*/)
|
| 696 |
+
return;
|
| 697 |
+
if (ch === 92/*\*/)
|
| 698 |
+
pos++;
|
| 699 |
+
}
|
| 700 |
+
syntaxError();
|
| 701 |
+
}
|
| 702 |
+
|
| 703 |
+
function blockComment (br) {
|
| 704 |
+
pos++;
|
| 705 |
+
while (pos++ < end) {
|
| 706 |
+
const ch = source.charCodeAt(pos);
|
| 707 |
+
if (!br && isBr(ch))
|
| 708 |
+
return;
|
| 709 |
+
if (ch === 42/***/ && source.charCodeAt(pos + 1) === 47/*/*/) {
|
| 710 |
+
pos++;
|
| 711 |
+
return;
|
| 712 |
+
}
|
| 713 |
+
}
|
| 714 |
+
}
|
| 715 |
+
|
| 716 |
+
function lineComment () {
|
| 717 |
+
while (pos++ < end) {
|
| 718 |
+
const ch = source.charCodeAt(pos);
|
| 719 |
+
if (ch === 10/*\n*/ || ch === 13/*\r*/)
|
| 720 |
+
return;
|
| 721 |
+
}
|
| 722 |
+
}
|
| 723 |
+
|
| 724 |
+
function stringLiteral (quote) {
|
| 725 |
+
while (pos++ < end) {
|
| 726 |
+
let ch = source.charCodeAt(pos);
|
| 727 |
+
if (ch === quote)
|
| 728 |
+
return;
|
| 729 |
+
if (ch === 92/*\*/) {
|
| 730 |
+
ch = source.charCodeAt(++pos);
|
| 731 |
+
if (ch === 13/*\r*/ && source.charCodeAt(pos + 1) === 10/*\n*/)
|
| 732 |
+
pos++;
|
| 733 |
+
}
|
| 734 |
+
else if (isBr(ch))
|
| 735 |
+
break;
|
| 736 |
+
}
|
| 737 |
+
syntaxError();
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
function regexCharacterClass () {
|
| 741 |
+
while (pos++ < end) {
|
| 742 |
+
let ch = source.charCodeAt(pos);
|
| 743 |
+
if (ch === 93/*]*/)
|
| 744 |
+
return ch;
|
| 745 |
+
if (ch === 92/*\*/)
|
| 746 |
+
pos++;
|
| 747 |
+
else if (ch === 10/*\n*/ || ch === 13/*\r*/)
|
| 748 |
+
break;
|
| 749 |
+
}
|
| 750 |
+
syntaxError();
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
+
function regularExpression () {
|
| 754 |
+
while (pos++ < end) {
|
| 755 |
+
let ch = source.charCodeAt(pos);
|
| 756 |
+
if (ch === 47/*/*/)
|
| 757 |
+
return;
|
| 758 |
+
if (ch === 91/*[*/)
|
| 759 |
+
ch = regexCharacterClass();
|
| 760 |
+
else if (ch === 92/*\*/)
|
| 761 |
+
pos++;
|
| 762 |
+
else if (ch === 10/*\n*/ || ch === 13/*\r*/)
|
| 763 |
+
break;
|
| 764 |
+
}
|
| 765 |
+
syntaxError();
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
function readToWsOrPunctuator (ch) {
|
| 769 |
+
do {
|
| 770 |
+
if (isBrOrWs(ch) || isPunctuator(ch))
|
| 771 |
+
return ch;
|
| 772 |
+
} while (ch = source.charCodeAt(++pos));
|
| 773 |
+
return ch;
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
// Note: non-asii BR and whitespace checks omitted for perf / footprint
|
| 777 |
+
// if there is a significant user need this can be reconsidered
|
| 778 |
+
function isBr (c) {
|
| 779 |
+
return c === 13/*\r*/ || c === 10/*\n*/;
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
function isWsNotBr (c) {
|
| 783 |
+
return c === 9 || c === 11 || c === 12 || c === 32 || c === 160;
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
function isBrOrWs (c) {
|
| 787 |
+
return c > 8 && c < 14 || c === 32 || c === 160;
|
| 788 |
+
}
|
| 789 |
+
|
| 790 |
+
function isBrOrWsOrPunctuatorNotDot (c) {
|
| 791 |
+
return c > 8 && c < 14 || c === 32 || c === 160 || isPunctuator(c) && c !== 46/*.*/;
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
function keywordStart (pos) {
|
| 795 |
+
return pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - 1));
|
| 796 |
+
}
|
| 797 |
+
|
| 798 |
+
function readPrecedingKeyword (pos, match) {
|
| 799 |
+
if (pos < match.length - 1)
|
| 800 |
+
return false;
|
| 801 |
+
return source.startsWith(match, pos - match.length + 1) && (pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - match.length)));
|
| 802 |
+
}
|
| 803 |
+
|
| 804 |
+
function readPrecedingKeyword1 (pos, ch) {
|
| 805 |
+
return source.charCodeAt(pos) === ch && (pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - 1)));
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
// Detects one of case, debugger, delete, do, else, in, instanceof, new,
|
| 809 |
+
// return, throw, typeof, void, yield, await
|
| 810 |
+
function isExpressionKeyword (pos) {
|
| 811 |
+
switch (source.charCodeAt(pos)) {
|
| 812 |
+
case 100/*d*/:
|
| 813 |
+
switch (source.charCodeAt(pos - 1)) {
|
| 814 |
+
case 105/*i*/:
|
| 815 |
+
// void
|
| 816 |
+
return readPrecedingKeyword(pos - 2, 'vo');
|
| 817 |
+
case 108/*l*/:
|
| 818 |
+
// yield
|
| 819 |
+
return readPrecedingKeyword(pos - 2, 'yie');
|
| 820 |
+
default:
|
| 821 |
+
return false;
|
| 822 |
+
}
|
| 823 |
+
case 101/*e*/:
|
| 824 |
+
switch (source.charCodeAt(pos - 1)) {
|
| 825 |
+
case 115/*s*/:
|
| 826 |
+
switch (source.charCodeAt(pos - 2)) {
|
| 827 |
+
case 108/*l*/:
|
| 828 |
+
// else
|
| 829 |
+
return readPrecedingKeyword1(pos - 3, 101/*e*/);
|
| 830 |
+
case 97/*a*/:
|
| 831 |
+
// case
|
| 832 |
+
return readPrecedingKeyword1(pos - 3, 99/*c*/);
|
| 833 |
+
default:
|
| 834 |
+
return false;
|
| 835 |
+
}
|
| 836 |
+
case 116/*t*/:
|
| 837 |
+
// delete
|
| 838 |
+
return readPrecedingKeyword(pos - 2, 'dele');
|
| 839 |
+
default:
|
| 840 |
+
return false;
|
| 841 |
+
}
|
| 842 |
+
case 102/*f*/:
|
| 843 |
+
if (source.charCodeAt(pos - 1) !== 111/*o*/ || source.charCodeAt(pos - 2) !== 101/*e*/)
|
| 844 |
+
return false;
|
| 845 |
+
switch (source.charCodeAt(pos - 3)) {
|
| 846 |
+
case 99/*c*/:
|
| 847 |
+
// instanceof
|
| 848 |
+
return readPrecedingKeyword(pos - 4, 'instan');
|
| 849 |
+
case 112/*p*/:
|
| 850 |
+
// typeof
|
| 851 |
+
return readPrecedingKeyword(pos - 4, 'ty');
|
| 852 |
+
default:
|
| 853 |
+
return false;
|
| 854 |
+
}
|
| 855 |
+
case 110/*n*/:
|
| 856 |
+
// in, return
|
| 857 |
+
return readPrecedingKeyword1(pos - 1, 105/*i*/) || readPrecedingKeyword(pos - 1, 'retur');
|
| 858 |
+
case 111/*o*/:
|
| 859 |
+
// do
|
| 860 |
+
return readPrecedingKeyword1(pos - 1, 100/*d*/);
|
| 861 |
+
case 114/*r*/:
|
| 862 |
+
// debugger
|
| 863 |
+
return readPrecedingKeyword(pos - 1, 'debugge');
|
| 864 |
+
case 116/*t*/:
|
| 865 |
+
// await
|
| 866 |
+
return readPrecedingKeyword(pos - 1, 'awai');
|
| 867 |
+
case 119/*w*/:
|
| 868 |
+
switch (source.charCodeAt(pos - 1)) {
|
| 869 |
+
case 101/*e*/:
|
| 870 |
+
// new
|
| 871 |
+
return readPrecedingKeyword1(pos - 2, 110/*n*/);
|
| 872 |
+
case 111/*o*/:
|
| 873 |
+
// throw
|
| 874 |
+
return readPrecedingKeyword(pos - 2, 'thr');
|
| 875 |
+
default:
|
| 876 |
+
return false;
|
| 877 |
+
}
|
| 878 |
+
}
|
| 879 |
+
return false;
|
| 880 |
+
}
|
| 881 |
+
|
| 882 |
+
function isParenKeyword (curPos) {
|
| 883 |
+
return source.charCodeAt(curPos) === 101/*e*/ && source.startsWith('whil', curPos - 4) ||
|
| 884 |
+
source.charCodeAt(curPos) === 114/*r*/ && source.startsWith('fo', curPos - 2) ||
|
| 885 |
+
source.charCodeAt(curPos - 1) === 105/*i*/ && source.charCodeAt(curPos) === 102/*f*/;
|
| 886 |
+
}
|
| 887 |
+
|
| 888 |
+
function isPunctuator (ch) {
|
| 889 |
+
// 23 possible punctuator endings: !%&()*+,-./:;<=>?[]^{}|~
|
| 890 |
+
return ch === 33/*!*/ || ch === 37/*%*/ || ch === 38/*&*/ ||
|
| 891 |
+
ch > 39 && ch < 48 || ch > 57 && ch < 64 ||
|
| 892 |
+
ch === 91/*[*/ || ch === 93/*]*/ || ch === 94/*^*/ ||
|
| 893 |
+
ch > 122 && ch < 127;
|
| 894 |
+
}
|
| 895 |
+
|
| 896 |
+
function isExpressionPunctuator (ch) {
|
| 897 |
+
// 20 possible expression endings: !%&(*+,-.:;<=>?[^{|~
|
| 898 |
+
return ch === 33/*!*/ || ch === 37/*%*/ || ch === 38/*&*/ ||
|
| 899 |
+
ch > 39 && ch < 47 && ch !== 41 || ch > 57 && ch < 64 ||
|
| 900 |
+
ch === 91/*[*/ || ch === 94/*^*/ || ch > 122 && ch < 127 && ch !== 125/*}*/;
|
| 901 |
+
}
|
| 902 |
+
|
| 903 |
+
function isExpressionTerminator (curPos) {
|
| 904 |
+
// detects:
|
| 905 |
+
// => ; ) finally catch else
|
| 906 |
+
// as all of these followed by a { will indicate a statement brace
|
| 907 |
+
switch (source.charCodeAt(curPos)) {
|
| 908 |
+
case 62/*>*/:
|
| 909 |
+
return source.charCodeAt(curPos - 1) === 61/*=*/;
|
| 910 |
+
case 59/*;*/:
|
| 911 |
+
case 41/*)*/:
|
| 912 |
+
return true;
|
| 913 |
+
case 104/*h*/:
|
| 914 |
+
return source.startsWith('catc', curPos - 4);
|
| 915 |
+
case 121/*y*/:
|
| 916 |
+
return source.startsWith('finall', curPos - 6);
|
| 917 |
+
case 101/*e*/:
|
| 918 |
+
return source.startsWith('els', curPos - 3);
|
| 919 |
+
}
|
| 920 |
+
return false;
|
| 921 |
+
}
|
| 922 |
+
|
| 923 |
+
function syntaxError () {
|
| 924 |
+
throw Object.assign(new Error(`Parse error ${name}:${source.slice(0, pos).split('\n').length}:${pos - source.lastIndexOf('\n', pos - 1)}`), { idx: pos });
|
| 925 |
+
}
|
node_modules/es-module-lexer/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "es-module-lexer",
|
| 3 |
+
"version": "1.7.0",
|
| 4 |
+
"description": "Lexes ES modules returning their import/export metadata",
|
| 5 |
+
"main": "dist/lexer.cjs",
|
| 6 |
+
"module": "dist/lexer.js",
|
| 7 |
+
"types": "types/lexer.d.ts",
|
| 8 |
+
"exports": {
|
| 9 |
+
".": {
|
| 10 |
+
"types": "./types/lexer.d.ts",
|
| 11 |
+
"module": "./dist/lexer.js",
|
| 12 |
+
"import": "./dist/lexer.js",
|
| 13 |
+
"require": "./dist/lexer.cjs"
|
| 14 |
+
},
|
| 15 |
+
"./js": {
|
| 16 |
+
"types": "./types/lexer.d.ts",
|
| 17 |
+
"default": "./dist/lexer.asm.js"
|
| 18 |
+
}
|
| 19 |
+
},
|
| 20 |
+
"scripts": {
|
| 21 |
+
"build": "npm install -g chomp ; chomp build",
|
| 22 |
+
"test": "npm install -g chomp ; chomp test"
|
| 23 |
+
},
|
| 24 |
+
"author": "Guy Bedford",
|
| 25 |
+
"license": "MIT",
|
| 26 |
+
"devDependencies": {
|
| 27 |
+
"@babel/cli": "^7.5.5",
|
| 28 |
+
"@babel/core": "^7.5.5",
|
| 29 |
+
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
|
| 30 |
+
"@swc/cli": "^0.1.57",
|
| 31 |
+
"@swc/core": "^1.2.224",
|
| 32 |
+
"@types/node": "^18.7.1",
|
| 33 |
+
"kleur": "^2.0.2",
|
| 34 |
+
"mocha": "^5.2.0",
|
| 35 |
+
"terser": "^5.19.4",
|
| 36 |
+
"typescript": "^4.7.4"
|
| 37 |
+
},
|
| 38 |
+
"files": [
|
| 39 |
+
"dist",
|
| 40 |
+
"types",
|
| 41 |
+
"lexer.js"
|
| 42 |
+
],
|
| 43 |
+
"type": "module",
|
| 44 |
+
"repository": {
|
| 45 |
+
"type": "git",
|
| 46 |
+
"url": "git+https://github.com/guybedford/es-module-lexer.git"
|
| 47 |
+
},
|
| 48 |
+
"bugs": {
|
| 49 |
+
"url": "https://github.com/guybedford/es-module-lexer/issues"
|
| 50 |
+
},
|
| 51 |
+
"homepage": "https://github.com/guybedford/es-module-lexer#readme",
|
| 52 |
+
"directories": {
|
| 53 |
+
"lib": "lib",
|
| 54 |
+
"test": "test"
|
| 55 |
+
},
|
| 56 |
+
"keywords": []
|
| 57 |
+
}
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export declare enum ImportType {
|
| 2 |
+
/**
|
| 3 |
+
* A normal static using any syntax variations
|
| 4 |
+
* import .. from 'module'
|
| 5 |
+
*/
|
| 6 |
+
Static = 1,
|
| 7 |
+
/**
|
| 8 |
+
* A dynamic import expression `import(specifier)`
|
| 9 |
+
* or `import(specifier, opts)`
|
| 10 |
+
*/
|
| 11 |
+
Dynamic = 2,
|
| 12 |
+
/**
|
| 13 |
+
* An import.meta expression
|
| 14 |
+
*/
|
| 15 |
+
ImportMeta = 3,
|
| 16 |
+
/**
|
| 17 |
+
* A source phase import
|
| 18 |
+
* import source x from 'module'
|
| 19 |
+
*/
|
| 20 |
+
StaticSourcePhase = 4,
|
| 21 |
+
/**
|
| 22 |
+
* A dynamic source phase import
|
| 23 |
+
* import.source('module')
|
| 24 |
+
*/
|
| 25 |
+
DynamicSourcePhase = 5,
|
| 26 |
+
/**
|
| 27 |
+
* A defer phase import
|
| 28 |
+
* import defer * as x from 'module'
|
| 29 |
+
*/
|
| 30 |
+
StaticDeferPhase = 6,
|
| 31 |
+
/**
|
| 32 |
+
* A dynamic defer phase import
|
| 33 |
+
* import.defer('module')
|
| 34 |
+
*/
|
| 35 |
+
DynamicDeferPhase = 7
|
| 36 |
+
}
|
| 37 |
+
export interface ImportSpecifier {
|
| 38 |
+
/**
|
| 39 |
+
* Module name
|
| 40 |
+
*
|
| 41 |
+
* To handle escape sequences in specifier strings, the .n field of imported specifiers will be provided where possible.
|
| 42 |
+
*
|
| 43 |
+
* For dynamic import expressions, this field will be empty if not a valid JS string.
|
| 44 |
+
* For static import expressions, this field will always be populated.
|
| 45 |
+
*
|
| 46 |
+
* @example
|
| 47 |
+
* const [imports1, exports1] = parse(String.raw`import './\u0061\u0062.js'`);
|
| 48 |
+
* imports1[0].n;
|
| 49 |
+
* // Returns "./ab.js"
|
| 50 |
+
*
|
| 51 |
+
* const [imports2, exports2] = parse(`import("./ab.js")`);
|
| 52 |
+
* imports2[0].n;
|
| 53 |
+
* // Returns "./ab.js"
|
| 54 |
+
*
|
| 55 |
+
* const [imports3, exports3] = parse(`import("./" + "ab.js")`);
|
| 56 |
+
* imports3[0].n;
|
| 57 |
+
* // Returns undefined
|
| 58 |
+
*/
|
| 59 |
+
readonly n: string | undefined;
|
| 60 |
+
/**
|
| 61 |
+
* Type of import statement
|
| 62 |
+
*/
|
| 63 |
+
readonly t: ImportType;
|
| 64 |
+
/**
|
| 65 |
+
* Start of module specifier
|
| 66 |
+
*
|
| 67 |
+
* @example
|
| 68 |
+
* const source = `import { a } from 'asdf'`;
|
| 69 |
+
* const [imports, exports] = parse(source);
|
| 70 |
+
* source.substring(imports[0].s, imports[0].e);
|
| 71 |
+
* // Returns "asdf"
|
| 72 |
+
*/
|
| 73 |
+
readonly s: number;
|
| 74 |
+
/**
|
| 75 |
+
* End of module specifier
|
| 76 |
+
*/
|
| 77 |
+
readonly e: number;
|
| 78 |
+
/**
|
| 79 |
+
* Start of import statement
|
| 80 |
+
*
|
| 81 |
+
* @example
|
| 82 |
+
* const source = `import { a } from 'asdf'`;
|
| 83 |
+
* const [imports, exports] = parse(source);
|
| 84 |
+
* source.substring(imports[0].ss, imports[0].se);
|
| 85 |
+
* // Returns "import { a } from 'asdf';"
|
| 86 |
+
*/
|
| 87 |
+
readonly ss: number;
|
| 88 |
+
/**
|
| 89 |
+
* End of import statement
|
| 90 |
+
*/
|
| 91 |
+
readonly se: number;
|
| 92 |
+
/**
|
| 93 |
+
* If this import keyword is a dynamic import, this is the start value.
|
| 94 |
+
* If this import keyword is a static import, this is -1.
|
| 95 |
+
* If this import keyword is an import.meta expresion, this is -2.
|
| 96 |
+
*/
|
| 97 |
+
readonly d: number;
|
| 98 |
+
/**
|
| 99 |
+
* If this import has an import assertion, this is the start value.
|
| 100 |
+
* Otherwise this is `-1`.
|
| 101 |
+
*/
|
| 102 |
+
readonly a: number;
|
| 103 |
+
}
|
| 104 |
+
export interface ExportSpecifier {
|
| 105 |
+
/**
|
| 106 |
+
* Exported name
|
| 107 |
+
*
|
| 108 |
+
* @example
|
| 109 |
+
* const source = `export default []`;
|
| 110 |
+
* const [imports, exports] = parse(source);
|
| 111 |
+
* exports[0].n;
|
| 112 |
+
* // Returns "default"
|
| 113 |
+
*
|
| 114 |
+
* @example
|
| 115 |
+
* const source = `export const asdf = 42`;
|
| 116 |
+
* const [imports, exports] = parse(source);
|
| 117 |
+
* exports[0].n;
|
| 118 |
+
* // Returns "asdf"
|
| 119 |
+
*/
|
| 120 |
+
readonly n: string;
|
| 121 |
+
/**
|
| 122 |
+
* Local name, or undefined.
|
| 123 |
+
*
|
| 124 |
+
* @example
|
| 125 |
+
* const source = `export default []`;
|
| 126 |
+
* const [imports, exports] = parse(source);
|
| 127 |
+
* exports[0].ln;
|
| 128 |
+
* // Returns undefined
|
| 129 |
+
*
|
| 130 |
+
* @example
|
| 131 |
+
* const asdf = 42;
|
| 132 |
+
* const source = `export { asdf as a }`;
|
| 133 |
+
* const [imports, exports] = parse(source);
|
| 134 |
+
* exports[0].ln;
|
| 135 |
+
* // Returns "asdf"
|
| 136 |
+
*/
|
| 137 |
+
readonly ln: string | undefined;
|
| 138 |
+
/**
|
| 139 |
+
* Start of exported name
|
| 140 |
+
*
|
| 141 |
+
* @example
|
| 142 |
+
* const source = `export default []`;
|
| 143 |
+
* const [imports, exports] = parse(source);
|
| 144 |
+
* source.substring(exports[0].s, exports[0].e);
|
| 145 |
+
* // Returns "default"
|
| 146 |
+
*
|
| 147 |
+
* @example
|
| 148 |
+
* const source = `export { 42 as asdf }`;
|
| 149 |
+
* const [imports, exports] = parse(source);
|
| 150 |
+
* source.substring(exports[0].s, exports[0].e);
|
| 151 |
+
* // Returns "asdf"
|
| 152 |
+
*/
|
| 153 |
+
readonly s: number;
|
| 154 |
+
/**
|
| 155 |
+
* End of exported name
|
| 156 |
+
*/
|
| 157 |
+
readonly e: number;
|
| 158 |
+
/**
|
| 159 |
+
* Start of local name, or -1.
|
| 160 |
+
*
|
| 161 |
+
* @example
|
| 162 |
+
* const asdf = 42;
|
| 163 |
+
* const source = `export { asdf as a }`;
|
| 164 |
+
* const [imports, exports] = parse(source);
|
| 165 |
+
* source.substring(exports[0].ls, exports[0].le);
|
| 166 |
+
* // Returns "asdf"
|
| 167 |
+
*/
|
| 168 |
+
readonly ls: number;
|
| 169 |
+
/**
|
| 170 |
+
* End of local name, or -1.
|
| 171 |
+
*/
|
| 172 |
+
readonly le: number;
|
| 173 |
+
}
|
| 174 |
+
export interface ParseError extends Error {
|
| 175 |
+
idx: number;
|
| 176 |
+
}
|
| 177 |
+
/**
|
| 178 |
+
* Outputs the list of exports and locations of import specifiers,
|
| 179 |
+
* including dynamic import and import meta handling.
|
| 180 |
+
*
|
| 181 |
+
* @param source Source code to parser
|
| 182 |
+
* @param name Optional sourcename
|
| 183 |
+
* @returns Tuple contaning imports list and exports list.
|
| 184 |
+
*/
|
| 185 |
+
export declare function parse(source: string, name?: string): readonly [
|
| 186 |
+
imports: ReadonlyArray<ImportSpecifier>,
|
| 187 |
+
exports: ReadonlyArray<ExportSpecifier>,
|
| 188 |
+
facade: boolean,
|
| 189 |
+
hasModuleSyntax: boolean
|
| 190 |
+
];
|
| 191 |
+
/**
|
| 192 |
+
* Wait for init to resolve before calling `parse`.
|
| 193 |
+
*/
|
| 194 |
+
export declare const init: Promise<void>;
|
| 195 |
+
export declare const initSync: () => void;
|
node_modules/es-object-atoms/.eslintrc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"root": true,
|
| 3 |
+
|
| 4 |
+
"extends": "@ljharb",
|
| 5 |
+
|
| 6 |
+
"rules": {
|
| 7 |
+
"eqeqeq": ["error", "allow-null"],
|
| 8 |
+
"id-length": "off",
|
| 9 |
+
"new-cap": ["error", {
|
| 10 |
+
"capIsNewExceptions": [
|
| 11 |
+
"RequireObjectCoercible",
|
| 12 |
+
"ToObject",
|
| 13 |
+
],
|
| 14 |
+
}],
|
| 15 |
+
},
|
| 16 |
+
}
|
node_modules/es-object-atoms/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# These are supported funding model platforms
|
| 2 |
+
|
| 3 |
+
github: [ljharb]
|
| 4 |
+
patreon: # Replace with a single Patreon username
|
| 5 |
+
open_collective: # Replace with a single Open Collective username
|
| 6 |
+
ko_fi: # Replace with a single Ko-fi username
|
| 7 |
+
tidelift: npm/es-object
|
| 8 |
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
| 9 |
+
liberapay: # Replace with a single Liberapay username
|
| 10 |
+
issuehunt: # Replace with a single IssueHunt username
|
| 11 |
+
otechie: # Replace with a single Otechie username
|
| 12 |
+
custom: # Replace with a single custom sponsorship URL
|
node_modules/es-object-atoms/CHANGELOG.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
All notable changes to this project will be documented in this file.
|
| 4 |
+
|
| 5 |
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
| 6 |
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
| 7 |
+
|
| 8 |
+
## [v1.1.1](https://github.com/ljharb/es-object-atoms/compare/v1.1.0...v1.1.1) - 2025-01-14
|
| 9 |
+
|
| 10 |
+
### Commits
|
| 11 |
+
|
| 12 |
+
- [types] `ToObject`: improve types [`cfe8c8a`](https://github.com/ljharb/es-object-atoms/commit/cfe8c8a105c44820cb22e26f62d12ef0ad9715c8)
|
| 13 |
+
|
| 14 |
+
## [v1.1.0](https://github.com/ljharb/es-object-atoms/compare/v1.0.1...v1.1.0) - 2025-01-14
|
| 15 |
+
|
| 16 |
+
### Commits
|
| 17 |
+
|
| 18 |
+
- [New] add `isObject` [`51e4042`](https://github.com/ljharb/es-object-atoms/commit/51e4042df722eb3165f40dc5f4bf33d0197ecb07)
|
| 19 |
+
|
| 20 |
+
## [v1.0.1](https://github.com/ljharb/es-object-atoms/compare/v1.0.0...v1.0.1) - 2025-01-13
|
| 21 |
+
|
| 22 |
+
### Commits
|
| 23 |
+
|
| 24 |
+
- [Dev Deps] update `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/tape`, `auto-changelog`, `tape` [`38ab9eb`](https://github.com/ljharb/es-object-atoms/commit/38ab9eb00b62c2f4668644f5e513d9b414ebd595)
|
| 25 |
+
- [types] improve types [`7d1beb8`](https://github.com/ljharb/es-object-atoms/commit/7d1beb887958b78b6a728a210a1c8370ab7e2aa1)
|
| 26 |
+
- [Tests] replace `aud` with `npm audit` [`25863ba`](https://github.com/ljharb/es-object-atoms/commit/25863baf99178f1d1ad33d1120498db28631907e)
|
| 27 |
+
- [Dev Deps] add missing peer dep [`c012309`](https://github.com/ljharb/es-object-atoms/commit/c0123091287e6132d6f4240496340c427433df28)
|
| 28 |
+
|
| 29 |
+
## v1.0.0 - 2024-03-16
|
| 30 |
+
|
| 31 |
+
### Commits
|
| 32 |
+
|
| 33 |
+
- Initial implementation, tests, readme, types [`f1499db`](https://github.com/ljharb/es-object-atoms/commit/f1499db7d3e1741e64979c61d645ab3137705e82)
|
| 34 |
+
- Initial commit [`99eedc7`](https://github.com/ljharb/es-object-atoms/commit/99eedc7b5fde38a50a28d3c8b724706e3e4c5f6a)
|
| 35 |
+
- [meta] rename repo [`fc851fa`](https://github.com/ljharb/es-object-atoms/commit/fc851fa70616d2d182aaf0bd02c2ed7084dea8fa)
|
| 36 |
+
- npm init [`b909377`](https://github.com/ljharb/es-object-atoms/commit/b909377c50049bd0ec575562d20b0f9ebae8947f)
|
| 37 |
+
- Only apps should have lockfiles [`7249edd`](https://github.com/ljharb/es-object-atoms/commit/7249edd2178c1b9ddfc66ffcc6d07fdf0d28efc1)
|
node_modules/es-object-atoms/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024 Jordan Harband
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/es-object-atoms/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# es-object-atoms <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
| 2 |
+
|
| 3 |
+
[![github actions][actions-image]][actions-url]
|
| 4 |
+
[![coverage][codecov-image]][codecov-url]
|
| 5 |
+
[![License][license-image]][license-url]
|
| 6 |
+
[![Downloads][downloads-image]][downloads-url]
|
| 7 |
+
|
| 8 |
+
[![npm badge][npm-badge-png]][package-url]
|
| 9 |
+
|
| 10 |
+
ES Object-related atoms: Object, ToObject, RequireObjectCoercible.
|
| 11 |
+
|
| 12 |
+
## Example
|
| 13 |
+
|
| 14 |
+
```js
|
| 15 |
+
const assert = require('assert');
|
| 16 |
+
|
| 17 |
+
const $Object = require('es-object-atoms');
|
| 18 |
+
const isObject = require('es-object-atoms/isObject');
|
| 19 |
+
const ToObject = require('es-object-atoms/ToObject');
|
| 20 |
+
const RequireObjectCoercible = require('es-object-atoms/RequireObjectCoercible');
|
| 21 |
+
|
| 22 |
+
assert.equal($Object, Object);
|
| 23 |
+
assert.throws(() => ToObject(null), TypeError);
|
| 24 |
+
assert.throws(() => ToObject(undefined), TypeError);
|
| 25 |
+
assert.throws(() => RequireObjectCoercible(null), TypeError);
|
| 26 |
+
assert.throws(() => RequireObjectCoercible(undefined), TypeError);
|
| 27 |
+
|
| 28 |
+
assert.equal(isObject(undefined), false);
|
| 29 |
+
assert.equal(isObject(null), false);
|
| 30 |
+
assert.equal(isObject({}), true);
|
| 31 |
+
assert.equal(isObject([]), true);
|
| 32 |
+
assert.equal(isObject(function () {}), true);
|
| 33 |
+
|
| 34 |
+
assert.deepEqual(RequireObjectCoercible(true), true);
|
| 35 |
+
assert.deepEqual(ToObject(true), Object(true));
|
| 36 |
+
|
| 37 |
+
const obj = {};
|
| 38 |
+
assert.equal(RequireObjectCoercible(obj), obj);
|
| 39 |
+
assert.equal(ToObject(obj), obj);
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
## Tests
|
| 43 |
+
Simply clone the repo, `npm install`, and run `npm test`
|
| 44 |
+
|
| 45 |
+
## Security
|
| 46 |
+
|
| 47 |
+
Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.
|
| 48 |
+
|
| 49 |
+
[package-url]: https://npmjs.org/package/es-object-atoms
|
| 50 |
+
[npm-version-svg]: https://versionbadg.es/ljharb/es-object-atoms.svg
|
| 51 |
+
[deps-svg]: https://david-dm.org/ljharb/es-object-atoms.svg
|
| 52 |
+
[deps-url]: https://david-dm.org/ljharb/es-object-atoms
|
| 53 |
+
[dev-deps-svg]: https://david-dm.org/ljharb/es-object-atoms/dev-status.svg
|
| 54 |
+
[dev-deps-url]: https://david-dm.org/ljharb/es-object-atoms#info=devDependencies
|
| 55 |
+
[npm-badge-png]: https://nodei.co/npm/es-object-atoms.png?downloads=true&stars=true
|
| 56 |
+
[license-image]: https://img.shields.io/npm/l/es-object-atoms.svg
|
| 57 |
+
[license-url]: LICENSE
|
| 58 |
+
[downloads-image]: https://img.shields.io/npm/dm/es-object.svg
|
| 59 |
+
[downloads-url]: https://npm-stat.com/charts.html?package=es-object-atoms
|
| 60 |
+
[codecov-image]: https://codecov.io/gh/ljharb/es-object-atoms/branch/main/graphs/badge.svg
|
| 61 |
+
[codecov-url]: https://app.codecov.io/gh/ljharb/es-object-atoms/
|
| 62 |
+
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/es-object-atoms
|
| 63 |
+
[actions-url]: https://github.com/ljharb/es-object-atoms/actions
|
node_modules/es-object-atoms/RequireObjectCoercible.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare function RequireObjectCoercible<T extends {}>(value: T, optMessage?: string): T;
|
| 2 |
+
|
| 3 |
+
export = RequireObjectCoercible;
|
node_modules/es-object-atoms/RequireObjectCoercible.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var $TypeError = require('es-errors/type');
|
| 4 |
+
|
| 5 |
+
/** @type {import('./RequireObjectCoercible')} */
|
| 6 |
+
module.exports = function RequireObjectCoercible(value) {
|
| 7 |
+
if (value == null) {
|
| 8 |
+
throw new $TypeError((arguments.length > 0 && arguments[1]) || ('Cannot call method on ' + value));
|
| 9 |
+
}
|
| 10 |
+
return value;
|
| 11 |
+
};
|
node_modules/es-object-atoms/ToObject.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare function ToObject<T extends object>(value: number): Number;
|
| 2 |
+
declare function ToObject<T extends object>(value: boolean): Boolean;
|
| 3 |
+
declare function ToObject<T extends object>(value: string): String;
|
| 4 |
+
declare function ToObject<T extends object>(value: bigint): BigInt;
|
| 5 |
+
declare function ToObject<T extends object>(value: T): T;
|
| 6 |
+
|
| 7 |
+
export = ToObject;
|
node_modules/es-object-atoms/ToObject.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var $Object = require('./');
|
| 4 |
+
var RequireObjectCoercible = require('./RequireObjectCoercible');
|
| 5 |
+
|
| 6 |
+
/** @type {import('./ToObject')} */
|
| 7 |
+
module.exports = function ToObject(value) {
|
| 8 |
+
RequireObjectCoercible(value);
|
| 9 |
+
return $Object(value);
|
| 10 |
+
};
|
node_modules/es-object-atoms/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare const Object: ObjectConstructor;
|
| 2 |
+
|
| 3 |
+
export = Object;
|
node_modules/es-object-atoms/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
/** @type {import('.')} */
|
| 4 |
+
module.exports = Object;
|
node_modules/es-object-atoms/isObject.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare function isObject(x: unknown): x is object;
|
| 2 |
+
|
| 3 |
+
export = isObject;
|
node_modules/es-object-atoms/isObject.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
/** @type {import('./isObject')} */
|
| 4 |
+
module.exports = function isObject(x) {
|
| 5 |
+
return !!x && (typeof x === 'function' || typeof x === 'object');
|
| 6 |
+
};
|
node_modules/es-object-atoms/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "es-object-atoms",
|
| 3 |
+
"version": "1.1.1",
|
| 4 |
+
"description": "ES Object-related atoms: Object, ToObject, RequireObjectCoercible",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"exports": {
|
| 7 |
+
".": "./index.js",
|
| 8 |
+
"./RequireObjectCoercible": "./RequireObjectCoercible.js",
|
| 9 |
+
"./isObject": "./isObject.js",
|
| 10 |
+
"./ToObject": "./ToObject.js",
|
| 11 |
+
"./package.json": "./package.json"
|
| 12 |
+
},
|
| 13 |
+
"sideEffects": false,
|
| 14 |
+
"scripts": {
|
| 15 |
+
"prepack": "npmignore --auto --commentLines=autogenerated",
|
| 16 |
+
"prepublishOnly": "safe-publish-latest",
|
| 17 |
+
"prepublish": "not-in-publish || npm run prepublishOnly",
|
| 18 |
+
"pretest": "npm run lint",
|
| 19 |
+
"test": "npm run tests-only",
|
| 20 |
+
"tests-only": "nyc tape 'test/**/*.js'",
|
| 21 |
+
"posttest": "npx npm@\">= 10.2\" audit --production",
|
| 22 |
+
"prelint": "evalmd README.md",
|
| 23 |
+
"lint": "eslint --ext=js,mjs .",
|
| 24 |
+
"postlint": "tsc -p . && eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git' | grep -v dist/)",
|
| 25 |
+
"version": "auto-changelog && git add CHANGELOG.md",
|
| 26 |
+
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
| 27 |
+
},
|
| 28 |
+
"repository": {
|
| 29 |
+
"type": "git",
|
| 30 |
+
"url": "git+https://github.com/ljharb/es-object-atoms.git"
|
| 31 |
+
},
|
| 32 |
+
"keywords": [
|
| 33 |
+
"javascript",
|
| 34 |
+
"ecmascript",
|
| 35 |
+
"object",
|
| 36 |
+
"toobject",
|
| 37 |
+
"coercible"
|
| 38 |
+
],
|
| 39 |
+
"author": "Jordan Harband <ljharb@gmail.com>",
|
| 40 |
+
"license": "MIT",
|
| 41 |
+
"bugs": {
|
| 42 |
+
"url": "https://github.com/ljharb/es-object-atoms/issues"
|
| 43 |
+
},
|
| 44 |
+
"homepage": "https://github.com/ljharb/es-object-atoms#readme",
|
| 45 |
+
"dependencies": {
|
| 46 |
+
"es-errors": "^1.3.0"
|
| 47 |
+
},
|
| 48 |
+
"devDependencies": {
|
| 49 |
+
"@ljharb/eslint-config": "^21.1.1",
|
| 50 |
+
"@ljharb/tsconfig": "^0.2.3",
|
| 51 |
+
"@types/tape": "^5.8.1",
|
| 52 |
+
"auto-changelog": "^2.5.0",
|
| 53 |
+
"eclint": "^2.8.1",
|
| 54 |
+
"encoding": "^0.1.13",
|
| 55 |
+
"eslint": "^8.8.0",
|
| 56 |
+
"evalmd": "^0.0.19",
|
| 57 |
+
"in-publish": "^2.0.1",
|
| 58 |
+
"npmignore": "^0.3.1",
|
| 59 |
+
"nyc": "^10.3.2",
|
| 60 |
+
"safe-publish-latest": "^2.0.0",
|
| 61 |
+
"tape": "^5.9.0",
|
| 62 |
+
"typescript": "next"
|
| 63 |
+
},
|
| 64 |
+
"auto-changelog": {
|
| 65 |
+
"output": "CHANGELOG.md",
|
| 66 |
+
"template": "keepachangelog",
|
| 67 |
+
"unreleased": false,
|
| 68 |
+
"commitLimit": false,
|
| 69 |
+
"backfillLimit": false,
|
| 70 |
+
"hideCredit": true
|
| 71 |
+
},
|
| 72 |
+
"publishConfig": {
|
| 73 |
+
"ignore": [
|
| 74 |
+
".github/workflows"
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
"engines": {
|
| 78 |
+
"node": ">= 0.4"
|
| 79 |
+
}
|
| 80 |
+
}
|
node_modules/es-object-atoms/test/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var test = require('tape');
|
| 4 |
+
|
| 5 |
+
var $Object = require('../');
|
| 6 |
+
var isObject = require('../isObject');
|
| 7 |
+
var ToObject = require('../ToObject');
|
| 8 |
+
var RequireObjectCoercible = require('..//RequireObjectCoercible');
|
| 9 |
+
|
| 10 |
+
test('errors', function (t) {
|
| 11 |
+
t.equal($Object, Object);
|
| 12 |
+
// @ts-expect-error
|
| 13 |
+
t['throws'](function () { ToObject(null); }, TypeError);
|
| 14 |
+
// @ts-expect-error
|
| 15 |
+
t['throws'](function () { ToObject(undefined); }, TypeError);
|
| 16 |
+
// @ts-expect-error
|
| 17 |
+
t['throws'](function () { RequireObjectCoercible(null); }, TypeError);
|
| 18 |
+
// @ts-expect-error
|
| 19 |
+
t['throws'](function () { RequireObjectCoercible(undefined); }, TypeError);
|
| 20 |
+
|
| 21 |
+
t.deepEqual(RequireObjectCoercible(true), true);
|
| 22 |
+
t.deepEqual(ToObject(true), Object(true));
|
| 23 |
+
t.deepEqual(ToObject(42), Object(42));
|
| 24 |
+
var f = function () {};
|
| 25 |
+
t.equal(ToObject(f), f);
|
| 26 |
+
|
| 27 |
+
t.equal(isObject(undefined), false);
|
| 28 |
+
t.equal(isObject(null), false);
|
| 29 |
+
t.equal(isObject({}), true);
|
| 30 |
+
t.equal(isObject([]), true);
|
| 31 |
+
t.equal(isObject(function () {}), true);
|
| 32 |
+
|
| 33 |
+
var obj = {};
|
| 34 |
+
t.equal(RequireObjectCoercible(obj), obj);
|
| 35 |
+
t.equal(ToObject(obj), obj);
|
| 36 |
+
|
| 37 |
+
t.end();
|
| 38 |
+
});
|