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
@types/iterate-value
TypeScript definitions for iterate-value
iterate-iterator
Iterate any JS iterator. Works robustly in all environments, all versions.
pop-iterate
A polymorphic iterate operator for arrays and other iterables
interpret
A dictionary of file extensions and associated module loaders.
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
-1.8%
429,093
Compared to previous day
Last week
2.2%
2,263,212
Compared to previous week
Last month
14.4%
9,369,914
Compared to previous month
Last year
-37.8%
123,556,427
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