pax_global_header 0000666 0000000 0000000 00000000064 14004077707 0014520 g ustar 00root root 0000000 0000000 52 comment=58601cc38b4608f33a8c1bfe932c79c1afc43ef0
es-get-iterator-1.1.2/ 0000775 0000000 0000000 00000000000 14004077707 0014534 5 ustar 00root root 0000000 0000000 es-get-iterator-1.1.2/.eslintignore 0000664 0000000 0000000 00000000104 14004077707 0017232 0 ustar 00root root 0000000 0000000 coverage/
# until eslint can parse `import.meta.url`
test/node.mjs
es-get-iterator-1.1.2/.eslintrc 0000664 0000000 0000000 00000000732 14004077707 0016362 0 ustar 00root root 0000000 0000000 {
"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,
},
},
],
}
es-get-iterator-1.1.2/.github/ 0000775 0000000 0000000 00000000000 14004077707 0016074 5 ustar 00root root 0000000 0000000 es-get-iterator-1.1.2/.github/FUNDING.yml 0000664 0000000 0000000 00000001061 14004077707 0017707 0 ustar 00root root 0000000 0000000 # 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
es-get-iterator-1.1.2/.github/workflows/ 0000775 0000000 0000000 00000000000 14004077707 0020131 5 ustar 00root root 0000000 0000000 es-get-iterator-1.1.2/.github/workflows/node-4+.yml 0000664 0000000 0000000 00000002316 14004077707 0022017 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: '>=4'
type: 'majors'
envs: "[{ \"TEST_VARIANT\": \"es6-shim\" }, { \"TEST_VARIANT\": \"es6-shim\", \"PRELOAD_GET_ITERATOR\": true }, { \"TEST_VARIANT\": \"core-js\", \"CORE_JS\": 2 }, { \"TEST_VARIANT\": \"core-js\", \"CORE_JS\": 3 }]"
latest:
needs: [matrix]
name: 'latest minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
shell-command: 'TEST_VARIANT=${{ matrix.envs.TEST_VARIANT }} npm run tests-only'
after_install: '[ -z "${{ matrix.envs.CORE_JS }}" ] || npm install core-js@${{ matrix.envs.CORE_JS }}'
node:
name: 'node 4+'
needs: [latest]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
es-get-iterator-1.1.2/.github/workflows/node-esm.yml 0000664 0000000 0000000 00000003267 14004077707 0022373 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js (ESM)'
on: [pull_request, push]
jobs:
latest:
name: 'notable ESM minors'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- node-version: '13.7'
envs:
TEST_VARIANT: node
- node-version: '13.7'
envs:
TEST_VARIANT: node.mjs
- node-version: '13.6'
envs:
TEST_VARIANT: node
- node-version: '13.5'
envs:
TEST_VARIANT: node
- node-version: '13.4'
envs:
TEST_VARIANT: node
- node-version: '13.3'
envs:
TEST_VARIANT: node
- node-version: '13.2'
envs:
TEST_VARIANT: node
- node-version: '13.2'
env:
TEST_VARIANT: node.mjs
- node-version: '13.1'
envs:
TEST_VARIANT: node
- node-version: '13.0'
envs:
TEST_VARIANT: node
- node-version: '12.17'
envs:
TEST_VARIANT: node.mjs
- node-version: '12.17'
envs:
TEST_VARIANT: node
- node-version: '12.16'
envs:
TEST_VARIANT: node
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
shell-command: 'TEST_VARIANT=${{ matrix.envs.TEST_VARIANT }} npm run tests-only'
node:
name: 'node, notable ESM minors'
needs: [latest]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
es-get-iterator-1.1.2/.github/workflows/node-iojs.yml 0000664 0000000 0000000 00000002312 14004077707 0022541 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js (io.js)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: 'iojs'
type: 'majors'
envs: "[{ \"TEST_VARIANT\": \"es6-shim\" }, { \"TEST_VARIANT\": \"es6-shim\", \"PRELOAD_GET_ITERATOR\": true }, { \"TEST_VARIANT\": \"core-js\", \"CORE_JS\": 2 }, { \"TEST_VARIANT\": \"core-js\", \"CORE_JS\": 3 }]"
latest:
needs: [matrix]
name: 'latest minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
shell-command: 'TEST_VARIANT=${{ matrix.envs.TEST_VARIANT }} npm run tests-only'
after_install: '[ -z "${{ matrix.envs.CORE_JS }}" ] || npm install core-js@${{ matrix.envs.CORE_JS }}'
node:
name: 'io.js'
needs: [latest]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
es-get-iterator-1.1.2/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000001067 14004077707 0023271 0 ustar 00root root 0000000 0000000 name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
pretest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run pretest'
with:
node-version: 'lts/*'
command: 'pretest'
posttest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run posttest'
with:
node-version: 'lts/*'
command: 'posttest'
es-get-iterator-1.1.2/.github/workflows/node-zero.yml 0000664 0000000 0000000 00000004131 14004077707 0022555 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js (0.x)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
stable: ${{ steps.set-matrix.outputs.requireds }}
unstable: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: '0.x'
envs: "[{ \"TEST_VARIANT\": \"es6-shim\" }, { \"TEST_VARIANT\": \"es6-shim\", \"PRELOAD_GET_ITERATOR\": true }, { \"TEST_VARIANT\": \"core-js\", \"CORE_JS\": 2 }, { \"TEST_VARIANT\": \"core-js\", \"CORE_JS\": 3 }]"
stable:
needs: [matrix]
name: 'stable minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.stable) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
shell-command: 'TEST_VARIANT=${{ matrix.envs.TEST_VARIANT }} npm run tests-only'
after_install: '[ -z "${{ matrix.envs.CORE_JS }}" ] || npm install core-js@${{ matrix.envs.CORE_JS }}'
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
skip-ls-check: true
unstable:
needs: [matrix, stable]
name: 'unstable minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.unstable) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
shell-command: 'TEST_VARIANT=${{ matrix.envs.TEST_VARIANT }} npm run tests-only'
after_install: '[ -z "${{ matrix.envs.CORE_JS }}" ] || npm install core-js@${{ matrix.envs.CORE_JS }}'
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
skip-ls-check: true
node:
name: 'node 0.x'
needs: [stable, unstable]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
es-get-iterator-1.1.2/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000401 14004077707 0022110 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
es-get-iterator-1.1.2/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000301 14004077707 0024544 0 ustar 00root root 0000000 0000000 name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
es-get-iterator-1.1.2/.gitignore 0000664 0000000 0000000 00000001745 14004077707 0016533 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
es-get-iterator-1.1.2/.npmignore 0000664 0000000 0000000 00000002011 14004077707 0016525 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
# github actions
.github/workflows
es-get-iterator-1.1.2/.npmrc 0000664 0000000 0000000 00000000067 14004077707 0015657 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
es-get-iterator-1.1.2/.nycrc 0000664 0000000 0000000 00000000330 14004077707 0015647 0 ustar 00root root 0000000 0000000 {
"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"
]
}
es-get-iterator-1.1.2/CHANGELOG.md 0000664 0000000 0000000 00000016560 14004077707 0016355 0 ustar 00root root 0000000 0000000 # 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)
es-get-iterator-1.1.2/LICENSE 0000664 0000000 0000000 00000002057 14004077707 0015545 0 ustar 00root root 0000000 0000000 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.
es-get-iterator-1.1.2/README.md 0000664 0000000 0000000 00000007076 14004077707 0016025 0 ustar 00root root 0000000 0000000 # es-get-iterator [![Version Badge][npm-version-svg]][package-url]
[![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
es-get-iterator-1.1.2/index.js 0000664 0000000 0000000 00000013737 14004077707 0016214 0 ustar 00root root 0000000 0000000 '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);
};
}
}
es-get-iterator-1.1.2/node.js 0000664 0000000 0000000 00000000564 14004077707 0016024 0 ustar 00root root 0000000 0000000 '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]();
}
};
es-get-iterator-1.1.2/node.mjs 0000664 0000000 0000000 00000000532 14004077707 0016174 0 ustar 00root root 0000000 0000000 // 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]();
}
}
es-get-iterator-1.1.2/package.json 0000664 0000000 0000000 00000004627 14004077707 0017033 0 ustar 00root root 0000000 0000000 {
"name": "es-get-iterator",
"version": "1.1.2",
"description": "Get an iterator for any JS language value. Works robustly across all environments, all versions.",
"main": "./index.js",
"browser": "./index.js",
"exports": {
".": [
{
"browser": "./index.js",
"import": "./node.mjs",
"default": "./node.js"
},
"./node.js"
],
"./package": "./package.json",
"./package.json": "./package.json"
},
"type": "commonjs",
"scripts": {
"prepublish": "safe-publish-latest",
"lint": "eslint --ext=js,mjs .",
"pretest": "npm run lint",
"tests-only": "nyc node test/${TEST_VARIANT-}",
"tests-esm": "TEST_VARIANT=node.mjs npm run tests-only",
"tests-preload-es6-shim": "TEST_VARIANT=es6-shim PRELOAD_GET_ITERATOR=true npm run tests-only",
"test": "npm run tests-only && npm run tests-esm && npm run tests-preload-es6-shim",
"posttest": "aud --production",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/ljharb/es-get-iterator.git"
},
"keywords": [
"iterator",
"Symbol.iterator",
"iterable",
"collection",
"next",
"iteration"
],
"author": "Jordan Harband ",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/ljharb/es-get-iterator/issues"
},
"homepage": "https://github.com/ljharb/es-get-iterator#readme",
"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"
},
"testling": {
"files": "./test/index.js"
},
"greenkeeper": {
"ignore": [
"nyc"
]
},
"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"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false
}
}
es-get-iterator-1.1.2/test/ 0000775 0000000 0000000 00000000000 14004077707 0015513 5 ustar 00root root 0000000 0000000 es-get-iterator-1.1.2/test/core-js.js 0000664 0000000 0000000 00000000063 14004077707 0017412 0 ustar 00root root 0000000 0000000 'use strict';
require('core-js');
require('./');
es-get-iterator-1.1.2/test/es6-shim.js 0000664 0000000 0000000 00000000261 14004077707 0017503 0 ustar 00root root 0000000 0000000 'use strict';
if (process.env.PRELOAD_GET_ITERATOR) {
// eslint-disable-next-line global-require
require('../');
}
require('es5-shim');
require('es6-shim');
require('./');
es-get-iterator-1.1.2/test/index.js 0000664 0000000 0000000 00000011741 14004077707 0017164 0 ustar 00root root 0000000 0000000 '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();
});
es-get-iterator-1.1.2/test/node.js 0000664 0000000 0000000 00000000036 14004077707 0016775 0 ustar 00root root 0000000 0000000 'use strict';
require('./');
es-get-iterator-1.1.2/test/node.mjs 0000664 0000000 0000000 00000000407 14004077707 0017154 0 ustar 00root root 0000000 0000000 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('./');