Gathering detailed insights and metrics for iterate-value
Gathering detailed insights and metrics for iterate-value
Gathering detailed insights and metrics for iterate-value
Gathering detailed insights and metrics for iterate-value
Iterate any iterable JS value. Works robustly in all environments, all versions.
npm install iterate-value
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Stars
48 Commits
3 Watching
1 Branches
1 Contributors
Updated on 09 Jun 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5.9%
401,050
Compared to previous day
Last week
0.8%
2,237,851
Compared to previous week
Last month
10.6%
9,394,559
Compared to previous month
Last year
-37.8%
123,389,680
Compared to previous year
Iterate any iterable JS value. Works robustly in all environments, all versions.
In modern engines, [...value]
or Array.from(value)
or for (const item of value) { }
are sufficient to iterate an iterable value (an object with a Symbol.iterator
method). However, older engines:
Symbol
, array spread, or for..of
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) and no syntax to support ites6-shim
or core-js
or similarThis library attempts to provide an abstraction over all that complexity!
If called with a single value, it will return an array of the yielded values. If also called with a callback function, it will instead call that callback once for each yielded value.
In node v13+, exports
is used by the es-get-iterator
dependency 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.
1var iterate = require('iterate-value'); 2var assert = require('assert'); 3 4assert.deepEqual(iterate('a 💩'), ['a', ' ', '💩']); 5assert.deepEqual(iterate([1, 2]), [1, 2]); 6assert.deepEqual(iterate(new Set([1, 2])), [1, 2]); 7assert.deepEqual(iterate(new Map([[1, 2], [3, 4]])), [[1, 2], [3, 4]]); 8 9function assertWithCallback(iterable, expected) { 10 var values = []; 11 var callback = function (x) { values.push(x); }; 12 iterate(iterable, callback); 13 assert.deepEqual(values, expected); 14} 15assertWithCallback('a 💩', ['a', ' ', '💩']); 16assertWithCallback([1, 2], [1, 2]); 17assertWithCallback(new Set([1, 2]), [1, 2]); 18assertWithCallback(new Map([[1, 2], [3, 4]]), [[1, 2], [3, 4]]);
Simply clone the repo, npm install
, and run npm test
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
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
Reason
SAST tool is not run on all commits -- score normalized to 0
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