Gathering detailed insights and metrics for es-get-iterator
Gathering detailed insights and metrics for es-get-iterator
Gathering detailed insights and metrics for es-get-iterator
Gathering detailed insights and metrics for es-get-iterator
Get an iterator for any JS language value. Works robustly across all environments, all versions.
npm install es-get-iterator
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
13 Stars
73 Commits
5 Forks
3 Watching
1 Branches
3 Contributors
Updated on 15 Jun 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-7.5%
2,215,245
Compared to previous day
Last week
0.6%
12,621,522
Compared to previous week
Last month
-3.8%
54,491,574
Compared to previous month
Last year
15%
629,389,555
Compared to previous year
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:
Symbol
support altogetherSymbol.iterator
but not implement it on everything it should, like arguments objectsMap
and Set
, but a non-standard name for the iterator-producing method (.iterator
or ['@@iterator']
, eg)es6-shim
or core-js
or similarThis 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.
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.
@rollup/plugin-replace
1// rollup.config.js 2 3import replace from '@rollup/plugin-replace'; 4 5export default { 6 ... 7 plugins: [ 8 replace({ 9 "require('has-symbols')()": 'true', 10 delimiters: ['', ''] 11 }) 12 ] 13};
1var getIterator = require('es-get-iterator'); 2var assert = require('assert'); 3 4var iterator = getIterator('a 💩'); 5assert.deepEqual( 6 [iterator.next(), iterator.next(), iterator.next(), iterator.next()], 7 [{ done: false, value: 'a' }, { done: false, value: ' ' }, { done: false, value: '💩' }, { done: true, value: undefined }] 8); 9 10var iterator = getIterator([1, 2]); 11assert.deepEqual( 12 [iterator.next(), iterator.next(), iterator.next()], 13 [{ done: false, value: 1 }, { done: false, value: 2 }, { done: true, value: undefined }] 14); 15 16var iterator = getIterator(new Set([1, 2])); 17assert.deepEqual( 18 [iterator.next(), iterator.next(), iterator.next()], 19 [{ done: false, value: 1 }, { done: false, value: 2 }, { done: true, value: undefined }] 20); 21 22var iterator = getIterator(new Map([[1, 2], [3, 4]])); 23assert.deepEqual( 24 [iterator.next(), iterator.next(), iterator.next()], 25 [{ done: false, value: [1, 2] }, { done: false, value: [3, 4] }, { done: true, value: undefined }] 26);
Simply clone the repo, npm install
, and run npm test
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More