Added some tests
This commit is contained in:
4
tests/node_modules/es-get-iterator/.eslintignore
generated
vendored
Normal file
4
tests/node_modules/es-get-iterator/.eslintignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
coverage/
|
||||
|
||||
# until eslint can parse `import.meta.url`
|
||||
test/node.mjs
|
||||
27
tests/node_modules/es-get-iterator/.eslintrc
generated
vendored
Normal file
27
tests/node_modules/es-get-iterator/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"consistent-return": 1,
|
||||
"eqeqeq": [2, "always", { "null": "ignore" }],
|
||||
"func-name-matching": 0,
|
||||
"id-length": 0,
|
||||
"max-lines-per-function": 0,
|
||||
"max-statements": 0,
|
||||
"multiline-comment-style": 0,
|
||||
"new-cap": [2, { "capIsNewExceptions": ["GetIntrinsic"] }],
|
||||
"no-magic-numbers": 0,
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"files": "test/**",
|
||||
"rules": {
|
||||
"max-params": [2, 3],
|
||||
"no-new-func": 1,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
12
tests/node_modules/es-get-iterator/.github/FUNDING.yml
generated
vendored
Normal file
12
tests/node_modules/es-get-iterator/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/es-get-iterator
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with a single custom sponsorship URL
|
||||
13
tests/node_modules/es-get-iterator/.nycrc
generated
vendored
Normal file
13
tests/node_modules/es-get-iterator/.nycrc
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"all": true,
|
||||
"check-coverage": false,
|
||||
"reporter": ["text-summary", "text", "html", "json"],
|
||||
"lines": 86,
|
||||
"statements": 85.93,
|
||||
"functions": 82.43,
|
||||
"branches": 76.06,
|
||||
"exclude": [
|
||||
"coverage",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
82
tests/node_modules/es-get-iterator/CHANGELOG.md
generated
vendored
Normal file
82
tests/node_modules/es-get-iterator/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
## [v1.1.2](https://github.com/ljharb/es-get-iterator/compare/v1.1.1...v1.1.2) - 2021-01-26
|
||||
|
||||
### Commits
|
||||
|
||||
- [meta] npmignore github action workflows [`0cd2f21`](https://github.com/ljharb/es-get-iterator/commit/0cd2f218f16b08efccbc29daf3831f4f37e30a74)
|
||||
- [readme] remove travis badge [`357065b`](https://github.com/ljharb/es-get-iterator/commit/357065b649cca3122cc32c73ef97739e3ab6cf6c)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `has-bigints`, `object-inspect`, `tape` [`13a77f2`](https://github.com/ljharb/es-get-iterator/commit/13a77f279cda7ddffbb769ea57933ffc3cac62f0)
|
||||
- [Deps] update `get-intrinsic`, `is-arguments`, `is-map`, `is-set` [`5f8d7f1`](https://github.com/ljharb/es-get-iterator/commit/5f8d7f14c71bffd470bb61f6f0e125da41bfcf06)
|
||||
- [meta] update actions, dotfiles [`5ea3e50`](https://github.com/ljharb/es-get-iterator/commit/5ea3e506d0ca1d80df6b37836c62e85934804f89)
|
||||
- [Tests] fix ESM test matrix [`9ab614c`](https://github.com/ljharb/es-get-iterator/commit/9ab614ce13b1a210d18827e47d4ad631a431dd39)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `es5-shim` [`e843ad9`](https://github.com/ljharb/es-get-iterator/commit/e843ad96802c3579a79b82ef49d98239f8288db8)
|
||||
- [Deps] update `call-bind`, `get-intrinsic` [`4301b3e`](https://github.com/ljharb/es-get-iterator/commit/4301b3e70982434feda67e5868d7a50f5101ae8f)
|
||||
- [meta] avoid upcoming deprecation warning in node; add "browser" field [`57297b1`](https://github.com/ljharb/es-get-iterator/commit/57297b19b54b0970fe986890be6c7a97fa4fdd3a)
|
||||
- [Tests] skip `npm ls` in node 0.x tests [`1409196`](https://github.com/ljharb/es-get-iterator/commit/1409196062de66d84d3cf1d368bed18488e767f2)
|
||||
- [Dev Deps] update `eslint` [`e4dcea4`](https://github.com/ljharb/es-get-iterator/commit/e4dcea49104de45a0bcf861f9aa2923f0209ed66)
|
||||
|
||||
## [v1.1.1](https://github.com/ljharb/es-get-iterator/compare/v1.1.0...v1.1.1) - 2020-11-06
|
||||
|
||||
### Commits
|
||||
|
||||
- [Tests] migrate tests to Github Actions [`e10fd31`](https://github.com/ljharb/es-get-iterator/commit/e10fd31909fc6451e4be5d8d9fb031d04ab72267)
|
||||
- [Fix] Support iterators defined by es6-shim when loaded after es-get-iterator [`f2ef7e1`](https://github.com/ljharb/es-get-iterator/commit/f2ef7e1d1cf5fa3357e460fc0023eaf11e79b573)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `es6-shim`, `object-inspect`, `tape` [`1ee86fc`](https://github.com/ljharb/es-get-iterator/commit/1ee86fcf0ff0fa115e78ef589d3a76cd299fe89e)
|
||||
- [actions] add "Allow Edits" workflow [`c785c69`](https://github.com/ljharb/es-get-iterator/commit/c785c69933afd98a670250f1d52e3b514cbd1d7a)
|
||||
- [Refactor] use `get-intrinsic` and `call-bind` instead of `es-abstract` [`65f4ef5`](https://github.com/ljharb/es-get-iterator/commit/65f4ef5018688432ca87a4b5aa971fee182722df)
|
||||
- [Dev Deps] update `auto-changelog`, `es5-shim`, `tape`; add `aud` [`91301ed`](https://github.com/ljharb/es-get-iterator/commit/91301edd87d6b753e0129ac7007e39d410030340)
|
||||
- [Dev Deps] update `aud` [`afc91d9`](https://github.com/ljharb/es-get-iterator/commit/afc91d98ae243c8563ac7295b8775c5a4b37c92f)
|
||||
- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`1962743`](https://github.com/ljharb/es-get-iterator/commit/19627437efac78d71d78d5e2ef0192052598bc1b)
|
||||
- [Deps] update `es-abstract` [`d2b57c8`](https://github.com/ljharb/es-get-iterator/commit/d2b57c8896b22eb90b0b894d80ba34f69ed68c3d)
|
||||
|
||||
## [v1.1.0](https://github.com/ljharb/es-get-iterator/compare/v1.0.2...v1.1.0) - 2020-01-25
|
||||
|
||||
### Commits
|
||||
|
||||
- [New] add native ESM variant via conditional exports [`325629d`](https://github.com/ljharb/es-get-iterator/commit/325629d43b6b8d4f2f5ff7d6623e81e01080dde7)
|
||||
- [Tests] fix test matrix [`01c20cf`](https://github.com/ljharb/es-get-iterator/commit/01c20cf6ed810e567f5fba5c29425df7f2aceb7a)
|
||||
- [Docs] Add modern browser example for Rollup [`ab9f17d`](https://github.com/ljharb/es-get-iterator/commit/ab9f17da94542940086280d8792d4e6c71186b47)
|
||||
- [Deps] update `is-map`, `is-set`, `es-abstract`, `is-string` [`a1b9645`](https://github.com/ljharb/es-get-iterator/commit/a1b964517cbd5b16a34fb15df50ec48d684c34c1)
|
||||
- [Fix] `node.js` only runs where "exports" is supported, and arguments is iterable there [`ccc7646`](https://github.com/ljharb/es-get-iterator/commit/ccc76469077f2fbc82fd4647894ebd660d21a2cb)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`4281453`](https://github.com/ljharb/es-get-iterator/commit/42814531965adb169abb3186a78c0926d4146232)
|
||||
- [Dev Deps] update `@ljharb/eslint-config` [`f4fc99c`](https://github.com/ljharb/es-get-iterator/commit/f4fc99c83935d0c03aade04030f103d5328abf15)
|
||||
- [Deps] update `es-abstract` [`70b0423`](https://github.com/ljharb/es-get-iterator/commit/70b042317239eb79df71b16a9531900bdad812f4)
|
||||
- [Tests] add string coverage for a lone surrogate not followed by a proper surrogate ending [`796e497`](https://github.com/ljharb/es-get-iterator/commit/796e4979168b6ee8ec323d54ca157296166e36d0)
|
||||
|
||||
## [v1.0.2](https://github.com/ljharb/es-get-iterator/compare/v1.0.1...v1.0.2) - 2019-12-16
|
||||
|
||||
### Commits
|
||||
|
||||
- [Deps] update `es-abstract` [`1554229`](https://github.com/ljharb/es-get-iterator/commit/15542291b91d82ccf9da063d1350e7fe685f6bcd)
|
||||
- [Dev Deps] update `eslint` [`577bbb1`](https://github.com/ljharb/es-get-iterator/commit/577bbb136f7c44cc2d774b0360061b1f1bb10f30)
|
||||
|
||||
## [v1.0.1](https://github.com/ljharb/es-get-iterator/compare/v1.0.0...v1.0.1) - 2019-11-27
|
||||
|
||||
### Commits
|
||||
|
||||
- [Fix] fix bugs in pre-Symbol environments [`592f78a`](https://github.com/ljharb/es-get-iterator/commit/592f78a1d38a0e3e3c4c3dafe1552899decd8c34)
|
||||
|
||||
## v1.0.0 - 2019-11-25
|
||||
|
||||
### Commits
|
||||
|
||||
- Initial tests. [`71f5fdd`](https://github.com/ljharb/es-get-iterator/commit/71f5fdd9c1fdd7b34b5c6f4e1a14cb0cbffc0d9c)
|
||||
- Initial implementation [`d7e0480`](https://github.com/ljharb/es-get-iterator/commit/d7e04808b322fb6648f4890d86df7f3384b53421)
|
||||
- Initial commit [`eb5372c`](https://github.com/ljharb/es-get-iterator/commit/eb5372c438b3ca4136e8253ffc4cc7834a4c8ca8)
|
||||
- readme [`8d6ad14`](https://github.com/ljharb/es-get-iterator/commit/8d6ad14a7f17339ccc20143562f0618773aba3b8)
|
||||
- npm init [`9b84446`](https://github.com/ljharb/es-get-iterator/commit/9b84446a4e346d4e12c59da5f2f928e1f71d3d69)
|
||||
- [meta] add `auto-changelog` [`e2d2e4f`](https://github.com/ljharb/es-get-iterator/commit/e2d2e4f55245b786581ef5d42d03cd0efb62db12)
|
||||
- [meta] add `funding` field; create FUNDING.yml [`5a31c77`](https://github.com/ljharb/es-get-iterator/commit/5a31c7722fc54edfe56975f5a4b7414c48136d36)
|
||||
- [actions] add automatic rebasing / merge commit blocking [`644429e`](https://github.com/ljharb/es-get-iterator/commit/644429e791abc1b85b65c90d0ee4aac57416ee90)
|
||||
- [Tests] add `npm run lint` [`f22172f`](https://github.com/ljharb/es-get-iterator/commit/f22172f2dcdd6f41ca45862698b8ea496134b164)
|
||||
- Only apps should have lockfiles [`fcf8441`](https://github.com/ljharb/es-get-iterator/commit/fcf8441df29d902647fd87d14224c7af19e40c31)
|
||||
- [meta] add `safe-publish-latest` [`946befa`](https://github.com/ljharb/es-get-iterator/commit/946befa7eb4a91ca648b98660b086ed7813cd3b1)
|
||||
- [Tests] only test on majors, since travis has a 200 build limit [`aeb5f09`](https://github.com/ljharb/es-get-iterator/commit/aeb5f09a66957c2cff0af22cb1a731ecafb82f24)
|
||||
21
tests/node_modules/es-get-iterator/LICENSE
generated
vendored
Normal file
21
tests/node_modules/es-get-iterator/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Jordan Harband
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
89
tests/node_modules/es-get-iterator/README.md
generated
vendored
Normal file
89
tests/node_modules/es-get-iterator/README.md
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
# es-get-iterator <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
||||
|
||||
[![dependency status][deps-svg]][deps-url]
|
||||
[![dev dependency status][dev-deps-svg]][dev-deps-url]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][npm-badge-png]][package-url]
|
||||
|
||||
Get an iterator for any JS language value. Works robustly across all environments, all versions.
|
||||
|
||||
In modern engines, `value[Symbol.iterator]()` is sufficient to produce an iterator (an object with a `.next` method) for that object. However, older engines:
|
||||
- may lack `Symbol` support altogether
|
||||
- may have `Symbol.iterator` but not implement it on everything it should, like arguments objects
|
||||
- may have `Map` and `Set`, but a non-standard name for the iterator-producing method (`.iterator` or `['@@iterator']`, eg)
|
||||
- may be old versions of Firefox that produce values until they throw a StopIteration exception, rather than having iteration result objects
|
||||
- may be polyfilled/shimmed/shammed, with `es6-shim` or `core-js` or similar
|
||||
|
||||
This library attempts to provide an abstraction over all that complexity!
|
||||
|
||||
In node v13+, `exports` is used to provide a lean implementation that lacks all the complexity described above, in combination with the `browser` field so that bundlers will pick up the proper implementation.
|
||||
|
||||
## Targeting browsers with Symbol support
|
||||
|
||||
If you are targeting browsers that definitely all have Symbol support, then you can configure your bundler to replace `require('has-symbols')()` with a literal `true`, which should allow dead code elimination to reduce the size of the bundled code.
|
||||
|
||||
### With `@rollup/plugin-replace`
|
||||
|
||||
```js
|
||||
// rollup.config.js
|
||||
|
||||
import replace from '@rollup/plugin-replace';
|
||||
|
||||
export default {
|
||||
...
|
||||
plugins: [
|
||||
replace({
|
||||
"require('has-symbols')()": 'true',
|
||||
delimiters: ['', '']
|
||||
})
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var getIterator = require('es-get-iterator');
|
||||
var assert = require('assert');
|
||||
|
||||
var iterator = getIterator('a 💩');
|
||||
assert.deepEqual(
|
||||
[iterator.next(), iterator.next(), iterator.next(), iterator.next()],
|
||||
[{ done: false, value: 'a' }, { done: false, value: ' ' }, { done: false, value: '💩' }, { done: true, value: undefined }]
|
||||
);
|
||||
|
||||
var iterator = getIterator([1, 2]);
|
||||
assert.deepEqual(
|
||||
[iterator.next(), iterator.next(), iterator.next()],
|
||||
[{ done: false, value: 1 }, { done: false, value: 2 }, { done: true, value: undefined }]
|
||||
);
|
||||
|
||||
var iterator = getIterator(new Set([1, 2]));
|
||||
assert.deepEqual(
|
||||
[iterator.next(), iterator.next(), iterator.next()],
|
||||
[{ done: false, value: 1 }, { done: false, value: 2 }, { done: true, value: undefined }]
|
||||
);
|
||||
|
||||
var iterator = getIterator(new Map([[1, 2], [3, 4]]));
|
||||
assert.deepEqual(
|
||||
[iterator.next(), iterator.next(), iterator.next()],
|
||||
[{ done: false, value: [1, 2] }, { done: false, value: [3, 4] }, { done: true, value: undefined }]
|
||||
);
|
||||
```
|
||||
|
||||
## Tests
|
||||
Simply clone the repo, `npm install`, and run `npm test`
|
||||
|
||||
[package-url]: https://npmjs.org/package/es-get-iterator
|
||||
[npm-version-svg]: https://versionbadg.es/ljharb/es-get-iterator.svg
|
||||
[deps-svg]: https://david-dm.org/ljharb/es-get-iterator.svg
|
||||
[deps-url]: https://david-dm.org/ljharb/es-get-iterator
|
||||
[dev-deps-svg]: https://david-dm.org/ljharb/es-get-iterator/dev-status.svg
|
||||
[dev-deps-url]: https://david-dm.org/ljharb/es-get-iterator#info=devDependencies
|
||||
[npm-badge-png]: https://nodei.co/npm/es-get-iterator.png?downloads=true&stars=true
|
||||
[license-image]: https://img.shields.io/npm/l/es-get-iterator.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: https://img.shields.io/npm/dm/es-get-iterator.svg
|
||||
[downloads-url]: https://npm-stat.com/charts.html?package=es-get-iterator
|
||||
207
tests/node_modules/es-get-iterator/index.js
generated
vendored
Normal file
207
tests/node_modules/es-get-iterator/index.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint global-require: 0 */
|
||||
// the code is structured this way so that bundlers can
|
||||
// alias out `has-symbols` to `() => true` or `() => false` if your target
|
||||
// environments' Symbol capabilities are known, and then use
|
||||
// dead code elimination on the rest of this module.
|
||||
//
|
||||
// Similarly, `isarray` can be aliased to `Array.isArray` if
|
||||
// available in all target environments.
|
||||
|
||||
var isArguments = require('is-arguments');
|
||||
|
||||
if (require('has-symbols')() || require('has-symbols/shams')()) {
|
||||
var $iterator = Symbol.iterator;
|
||||
// Symbol is available natively or shammed
|
||||
// natively:
|
||||
// - Chrome >= 38
|
||||
// - Edge 12-14?, Edge >= 15 for sure
|
||||
// - FF >= 36
|
||||
// - Safari >= 9
|
||||
// - node >= 0.12
|
||||
module.exports = function getIterator(iterable) {
|
||||
// alternatively, `iterable[$iterator]?.()`
|
||||
if (iterable != null && typeof iterable[$iterator] !== 'undefined') {
|
||||
return iterable[$iterator]();
|
||||
}
|
||||
if (isArguments(iterable)) {
|
||||
// arguments objects lack Symbol.iterator
|
||||
// - node 0.12
|
||||
return Array.prototype[$iterator].call(iterable);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// Symbol is not available, native or shammed
|
||||
var isArray = require('isarray');
|
||||
var isString = require('is-string');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var $Map = GetIntrinsic('%Map%', true);
|
||||
var $Set = GetIntrinsic('%Set%', true);
|
||||
var callBound = require('call-bind/callBound');
|
||||
var $arrayPush = callBound('Array.prototype.push');
|
||||
var $charCodeAt = callBound('String.prototype.charCodeAt');
|
||||
var $stringSlice = callBound('String.prototype.slice');
|
||||
|
||||
var advanceStringIndex = function advanceStringIndex(S, index) {
|
||||
var length = S.length;
|
||||
if ((index + 1) >= length) {
|
||||
return index + 1;
|
||||
}
|
||||
|
||||
var first = $charCodeAt(S, index);
|
||||
if (first < 0xD800 || first > 0xDBFF) {
|
||||
return index + 1;
|
||||
}
|
||||
|
||||
var second = $charCodeAt(S, index + 1);
|
||||
if (second < 0xDC00 || second > 0xDFFF) {
|
||||
return index + 1;
|
||||
}
|
||||
|
||||
return index + 2;
|
||||
};
|
||||
|
||||
var getArrayIterator = function getArrayIterator(arraylike) {
|
||||
var i = 0;
|
||||
return {
|
||||
next: function next() {
|
||||
var done = i >= arraylike.length;
|
||||
var value;
|
||||
if (!done) {
|
||||
value = arraylike[i];
|
||||
i += 1;
|
||||
}
|
||||
return {
|
||||
done: done,
|
||||
value: value
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var getNonCollectionIterator = function getNonCollectionIterator(iterable, noPrimordialCollections) {
|
||||
if (isArray(iterable) || isArguments(iterable)) {
|
||||
return getArrayIterator(iterable);
|
||||
}
|
||||
if (isString(iterable)) {
|
||||
var i = 0;
|
||||
return {
|
||||
next: function next() {
|
||||
var nextIndex = advanceStringIndex(iterable, i);
|
||||
var value = $stringSlice(iterable, i, nextIndex);
|
||||
i = nextIndex;
|
||||
return {
|
||||
done: nextIndex > iterable.length,
|
||||
value: value
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// es6-shim and es-shims' es-map use a string "_es6-shim iterator_" property on different iterables, such as MapIterator.
|
||||
if (noPrimordialCollections && typeof iterable['_es6-shim iterator_'] !== 'undefined') {
|
||||
return iterable['_es6-shim iterator_']();
|
||||
}
|
||||
};
|
||||
|
||||
if (!$Map && !$Set) {
|
||||
// the only language iterables are Array, String, arguments
|
||||
// - Safari <= 6.0
|
||||
// - Chrome < 38
|
||||
// - node < 0.12
|
||||
// - FF < 13
|
||||
// - IE < 11
|
||||
// - Edge < 11
|
||||
|
||||
module.exports = function getIterator(iterable) {
|
||||
if (iterable != null) {
|
||||
return getNonCollectionIterator(iterable, true);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// either Map or Set are available, but Symbol is not
|
||||
// - es6-shim on an ES5 browser
|
||||
// - Safari 6.2 (maybe 6.1?)
|
||||
// - FF v[13, 36)
|
||||
// - IE 11
|
||||
// - Edge 11
|
||||
// - Safari v[6, 9)
|
||||
|
||||
var isMap = require('is-map');
|
||||
var isSet = require('is-set');
|
||||
|
||||
// Firefox >= 27, IE 11, Safari 6.2 - 9, Edge 11, es6-shim in older envs, all have forEach
|
||||
var $mapForEach = callBound('Map.prototype.forEach', true);
|
||||
var $setForEach = callBound('Set.prototype.forEach', true);
|
||||
if (typeof process === 'undefined' || !process.versions || !process.versions.node) { // "if is not node"
|
||||
|
||||
// Firefox 17 - 26 has `.iterator()`, whose iterator `.next()` either
|
||||
// returns a value, or throws a StopIteration object. These browsers
|
||||
// do not have any other mechanism for iteration.
|
||||
var $mapIterator = callBound('Map.prototype.iterator', true);
|
||||
var $setIterator = callBound('Set.prototype.iterator', true);
|
||||
var getStopIterationIterator = function (iterator) {
|
||||
var done = false;
|
||||
return {
|
||||
next: function next() {
|
||||
try {
|
||||
return {
|
||||
done: done,
|
||||
value: done ? undefined : iterator.next()
|
||||
};
|
||||
} catch (e) {
|
||||
done = true;
|
||||
return {
|
||||
done: true,
|
||||
value: undefined
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
// Firefox 27-35, and some older es6-shim versions, use a string "@@iterator" property
|
||||
// this returns a proper iterator object, so we should use it instead of forEach.
|
||||
// newer es6-shim versions use a string "_es6-shim iterator_" property.
|
||||
var $mapAtAtIterator = callBound('Map.prototype.@@iterator', true) || callBound('Map.prototype._es6-shim iterator_', true);
|
||||
var $setAtAtIterator = callBound('Set.prototype.@@iterator', true) || callBound('Set.prototype._es6-shim iterator_', true);
|
||||
|
||||
var getCollectionIterator = function getCollectionIterator(iterable) {
|
||||
if (isMap(iterable)) {
|
||||
if ($mapIterator) {
|
||||
return getStopIterationIterator($mapIterator(iterable));
|
||||
}
|
||||
if ($mapAtAtIterator) {
|
||||
return $mapAtAtIterator(iterable);
|
||||
}
|
||||
if ($mapForEach) {
|
||||
var entries = [];
|
||||
$mapForEach(iterable, function (v, k) {
|
||||
$arrayPush(entries, [k, v]);
|
||||
});
|
||||
return getArrayIterator(entries);
|
||||
}
|
||||
}
|
||||
if (isSet(iterable)) {
|
||||
if ($setIterator) {
|
||||
return getStopIterationIterator($setIterator(iterable));
|
||||
}
|
||||
if ($setAtAtIterator) {
|
||||
return $setAtAtIterator(iterable);
|
||||
}
|
||||
if ($setForEach) {
|
||||
var values = [];
|
||||
$setForEach(iterable, function (v) {
|
||||
$arrayPush(values, v);
|
||||
});
|
||||
return getArrayIterator(values);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function getIterator(iterable) {
|
||||
return getCollectionIterator(iterable) || getNonCollectionIterator(iterable);
|
||||
};
|
||||
}
|
||||
}
|
||||
12
tests/node_modules/es-get-iterator/node.js
generated
vendored
Normal file
12
tests/node_modules/es-get-iterator/node.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
// this should only run in node >= 13.2, so it
|
||||
// does not need any of the intense fallbacks that old node/browsers do
|
||||
|
||||
var $iterator = Symbol.iterator;
|
||||
module.exports = function getIterator(iterable) {
|
||||
// alternatively, `iterable[$iterator]?.()`
|
||||
if (iterable != null && typeof iterable[$iterator] !== 'undefined') {
|
||||
return iterable[$iterator]();
|
||||
}
|
||||
};
|
||||
11
tests/node_modules/es-get-iterator/node.mjs
generated
vendored
Normal file
11
tests/node_modules/es-get-iterator/node.mjs
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// this should only run in node >= 13.7, so it
|
||||
// does not need any of the intense fallbacks that old node/browsers do
|
||||
|
||||
var $iterator = Symbol.iterator;
|
||||
|
||||
export default function getIterator(iterable) {
|
||||
// alternatively, `iterable[$iterator]?.()`
|
||||
if (iterable != null && iterable[$iterator] !== undefined) {
|
||||
return iterable[$iterator]();
|
||||
}
|
||||
}
|
||||
121
tests/node_modules/es-get-iterator/package.json
generated
vendored
Normal file
121
tests/node_modules/es-get-iterator/package.json
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
{
|
||||
"_from": "es-get-iterator@^1.1.1",
|
||||
"_id": "es-get-iterator@1.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-+DTO8GYwbMCwbywjimwZMHp8AuYXOS2JZFWoi2AlPOS3ebnII9w/NLpNZtA7A0YLaVDw+O7KFCeoIV7OPvM7hQ==",
|
||||
"_location": "/es-get-iterator",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "es-get-iterator@^1.1.1",
|
||||
"name": "es-get-iterator",
|
||||
"escapedName": "es-get-iterator",
|
||||
"rawSpec": "^1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/deep-equal"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.2.tgz",
|
||||
"_shasum": "9234c54aba713486d7ebde0220864af5e2b283f7",
|
||||
"_spec": "es-get-iterator@^1.1.1",
|
||||
"_where": "/home/lilleman/go/src/gitlab.larvit.se/power-plan/auth/tests/node_modules/deep-equal",
|
||||
"author": {
|
||||
"name": "Jordan Harband",
|
||||
"email": "ljharb@gmail.com"
|
||||
},
|
||||
"auto-changelog": {
|
||||
"output": "CHANGELOG.md",
|
||||
"template": "keepachangelog",
|
||||
"unreleased": false,
|
||||
"commitLimit": false,
|
||||
"backfillLimit": false
|
||||
},
|
||||
"browser": "./index.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ljharb/es-get-iterator/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"get-intrinsic": "^1.1.0",
|
||||
"has-symbols": "^1.0.1",
|
||||
"is-arguments": "^1.1.0",
|
||||
"is-map": "^2.0.2",
|
||||
"is-set": "^2.0.2",
|
||||
"is-string": "^1.0.5",
|
||||
"isarray": "^2.0.5"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Get an iterator for any JS language value. Works robustly across all environments, all versions.",
|
||||
"devDependencies": {
|
||||
"@ljharb/eslint-config": "^17.5.0",
|
||||
"aud": "^1.1.3",
|
||||
"auto-changelog": "^2.2.1",
|
||||
"core-js": "^2.6.10 || ^3.4.2",
|
||||
"es5-shim": "^4.5.15",
|
||||
"es6-shim": "^0.35.6",
|
||||
"eslint": "^7.18.0",
|
||||
"for-each": "^0.3.3",
|
||||
"has-bigints": "^1.0.1",
|
||||
"nyc": "^10.3.2",
|
||||
"object-inspect": "^1.9.0",
|
||||
"safe-publish-latest": "^1.1.4",
|
||||
"tape": "^5.1.1"
|
||||
},
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"browser": "./index.js",
|
||||
"import": "./node.mjs",
|
||||
"default": "./node.js"
|
||||
},
|
||||
"./node.js"
|
||||
],
|
||||
"./package": "./package.json",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
},
|
||||
"greenkeeper": {
|
||||
"ignore": [
|
||||
"nyc"
|
||||
]
|
||||
},
|
||||
"homepage": "https://github.com/ljharb/es-get-iterator#readme",
|
||||
"keywords": [
|
||||
"iterator",
|
||||
"Symbol.iterator",
|
||||
"iterable",
|
||||
"collection",
|
||||
"next",
|
||||
"iteration"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./index.js",
|
||||
"name": "es-get-iterator",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ljharb/es-get-iterator.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --ext=js,mjs .",
|
||||
"posttest": "aud --production",
|
||||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"",
|
||||
"prepublish": "safe-publish-latest",
|
||||
"pretest": "npm run lint",
|
||||
"test": "npm run tests-only && npm run tests-esm && npm run tests-preload-es6-shim",
|
||||
"tests-esm": "TEST_VARIANT=node.mjs npm run tests-only",
|
||||
"tests-only": "nyc node test/${TEST_VARIANT-}",
|
||||
"tests-preload-es6-shim": "TEST_VARIANT=es6-shim PRELOAD_GET_ITERATOR=true npm run tests-only",
|
||||
"version": "auto-changelog && git add CHANGELOG.md"
|
||||
},
|
||||
"testling": {
|
||||
"files": "./test/index.js"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"version": "1.1.2"
|
||||
}
|
||||
5
tests/node_modules/es-get-iterator/test/core-js.js
generated
vendored
Normal file
5
tests/node_modules/es-get-iterator/test/core-js.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
require('core-js');
|
||||
|
||||
require('./');
|
||||
11
tests/node_modules/es-get-iterator/test/es6-shim.js
generated
vendored
Normal file
11
tests/node_modules/es-get-iterator/test/es6-shim.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.PRELOAD_GET_ITERATOR) {
|
||||
// eslint-disable-next-line global-require
|
||||
require('../');
|
||||
}
|
||||
|
||||
require('es5-shim');
|
||||
require('es6-shim');
|
||||
|
||||
require('./');
|
||||
176
tests/node_modules/es-get-iterator/test/index.js
generated
vendored
Normal file
176
tests/node_modules/es-get-iterator/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var Test = require('tape/lib/test');
|
||||
var inspect = require('object-inspect');
|
||||
// eslint-disable-next-line global-require
|
||||
var hasSymbols = require('has-symbols')() || require('has-symbols/shams')();
|
||||
var hasBigInts = require('has-bigints')();
|
||||
var forEach = require('for-each');
|
||||
|
||||
var getIterator = process.env.TEST_VARIANT === 'node' ? require('../node') : require('../');
|
||||
|
||||
Test.prototype.iterate = function (value, expected, message) {
|
||||
var i = 0;
|
||||
this.test(message, function (t) {
|
||||
var iterator = getIterator(value);
|
||||
if (!iterator) {
|
||||
t.fail(inspect(value) + ' is not iterable');
|
||||
return t.end();
|
||||
}
|
||||
if (typeof iterator.next !== 'function') {
|
||||
t.fail('iterator does not have a next function, got ' + inspect(iterator));
|
||||
return t.end();
|
||||
}
|
||||
var result;
|
||||
while ((result = iterator.next()) && !result.done) {
|
||||
t.deepEqual(result.value, expected[i], 'index ' + i + ': expected ' + inspect(expected[i]) + ', got ' + inspect(result.value));
|
||||
i += 1;
|
||||
}
|
||||
t.equal(i, expected.length, 'expected ' + expected.length + ' values, got ' + i + ' values');
|
||||
|
||||
t.end();
|
||||
});
|
||||
};
|
||||
|
||||
Test.prototype.noIterate = function (value) {
|
||||
this.equal(getIterator(value), undefined, inspect(value) + ' is not iterable');
|
||||
};
|
||||
|
||||
Test.prototype.fakeIterator = function (value) {
|
||||
this.test(inspect(value) + ' with a fake iterator', { skip: !hasSymbols }, function (t) {
|
||||
var fakeValues = ['fake', 'iterator', 'scary'];
|
||||
var o = Object(value);
|
||||
o[Symbol.iterator] = function () {
|
||||
return getIterator(fakeValues);
|
||||
};
|
||||
t.iterate(o, fakeValues, inspect(o) + ' with an overwritten iterator method, yields those values instead');
|
||||
t.end();
|
||||
});
|
||||
};
|
||||
|
||||
var getArguments = function () { return arguments; };
|
||||
var getSloppyArguments = Function('return arguments');
|
||||
|
||||
var collect = function createCollection(C, items) {
|
||||
var c = new C();
|
||||
forEach(items, function (item) {
|
||||
if (c.add) {
|
||||
c.add(item);
|
||||
} else {
|
||||
c.set(item[0], item[1]);
|
||||
}
|
||||
});
|
||||
return c;
|
||||
};
|
||||
|
||||
var runTests = function runTests(t) {
|
||||
t.test('strings', function (st) {
|
||||
st.iterate('', [], '"" yields nothing');
|
||||
st.iterate(Object(''), [], inspect(Object('')) + ' yields nothing');
|
||||
st.iterate('foo', ['f', 'o', 'o'], '"foo" yields three chars');
|
||||
st.iterate(Object('foo'), ['f', 'o', 'o'], inspect(Object('foo')) + ' yields three chars');
|
||||
st.iterate('a💩z', ['a', '💩', 'z'], '"a💩z" yields three code points');
|
||||
st.iterate(Object('a💩z'), ['a', '💩', 'z'], inspect(Object('a💩z')) + ' yields three code points');
|
||||
st.iterate('\ud83dX', ['\ud83d', 'X'], inspect('\ud83dX') + ' (lone surrogate followed by "not a lone surrogate ending") yields one code point');
|
||||
|
||||
st.fakeIterator('abc');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('arrays', function (st) {
|
||||
st.iterate([], [], '[] yields nothing');
|
||||
st.iterate([1, 2], [1, 2], '[1, 2] yields [1, 2]');
|
||||
// eslint-disable-next-line no-sparse-arrays
|
||||
st.iterate([1, , 3], [1, undefined, 3], 'sparse array does not skip holes');
|
||||
|
||||
st.fakeIterator([1, 2, 3]);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('arguments', function (st) {
|
||||
st.iterate(getArguments(), [], 'empty arguments object yields nothing');
|
||||
st.iterate(getSloppyArguments(), [], 'empty sloppy arguments object yields nothing');
|
||||
st.iterate(getArguments(1, 2, 3), [1, 2, 3], 'arguments object yields all args');
|
||||
st.iterate(getSloppyArguments(1, 2, 3), [1, 2, 3], 'sloppy arguments object yields all args');
|
||||
|
||||
st.fakeIterator(getArguments(1, 2, 3));
|
||||
st.fakeIterator(getSloppyArguments(1, 2, 3));
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('non-iterables', function (st) {
|
||||
var numbers = [0, -0, NaN, Infinity, 42];
|
||||
var nonIterables = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
{},
|
||||
/a/g,
|
||||
function () {}
|
||||
];
|
||||
if (hasSymbols) {
|
||||
nonIterables.push(Symbol.iterator);
|
||||
}
|
||||
if (hasBigInts) {
|
||||
nonIterables.push(BigInt(42), BigInt(0));
|
||||
}
|
||||
forEach(nonIterables, function (nonIterable) {
|
||||
st.noIterate(nonIterable);
|
||||
if (nonIterable != null) {
|
||||
st.fakeIterator(nonIterable);
|
||||
}
|
||||
});
|
||||
if (hasSymbols && NaN[Symbol.iterator]) {
|
||||
st.comment('# SKIP core-js v2 makes numbers iterable, in violation of the spec');
|
||||
}
|
||||
forEach(numbers, function (number) {
|
||||
if (!hasSymbols || !number[Symbol.iterator]) {
|
||||
st.noIterate(number);
|
||||
}
|
||||
st.fakeIterator(number);
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('Map', { skip: typeof Map !== 'function' }, function (st) {
|
||||
st.iterate(new Map(), [], 'empty Map yields nothing');
|
||||
var entries = [
|
||||
[1, 'a'],
|
||||
[2, 'b'],
|
||||
[3, 'c']
|
||||
];
|
||||
var m = collect(Map, entries);
|
||||
st.iterate(m, entries, inspect(m) + ' yields expected entries');
|
||||
|
||||
st.fakeIterator(collect(Map, entries));
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('Set', { skip: typeof Set !== 'function' }, function (st) {
|
||||
st.iterate(new Set(), [], 'empty Set yields nothing');
|
||||
var values = [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
];
|
||||
var s = collect(Set, values);
|
||||
st.iterate(s, values, inspect(s) + ' yields expected values');
|
||||
|
||||
st.fakeIterator(collect(Set, values));
|
||||
|
||||
st.end();
|
||||
});
|
||||
};
|
||||
|
||||
test((process.env.TEST_VARIANT || 'standard') + ': getIterator tests', function (t) {
|
||||
runTests(t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
3
tests/node_modules/es-get-iterator/test/node.js
generated
vendored
Normal file
3
tests/node_modules/es-get-iterator/test/node.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
require('./');
|
||||
10
tests/node_modules/es-get-iterator/test/node.mjs
generated
vendored
Normal file
10
tests/node_modules/es-get-iterator/test/node.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import getIterator from 'es-get-iterator';
|
||||
import Module from 'module';
|
||||
|
||||
const require = Module.createRequire(import.meta.url);
|
||||
const id = require.resolve('../node');
|
||||
const mod = new Module(id);
|
||||
mod.exports = getIterator;
|
||||
require.cache[id] = mod;
|
||||
|
||||
require('./');
|
||||
Reference in New Issue
Block a user