Gathering detailed insights and metrics for iterate-iterator
Gathering detailed insights and metrics for iterate-iterator
Gathering detailed insights and metrics for iterate-iterator
Gathering detailed insights and metrics for iterate-iterator
Iterate any JS iterator. Works robustly in all environments, all versions.
npm install iterate-iterator
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Stars
44 Commits
3 Watching
1 Branches
1 Contributors
Updated on 03 Jun 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-6.3%
401,764
Compared to previous day
Last week
0.7%
2,240,671
Compared to previous week
Last month
10.3%
9,413,449
Compared to previous month
Last year
-38.3%
124,012,347
Compared to previous year
Iterate any iterable JS iterator. 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), which includes all builtin iterators. 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 simplifies iterating an iterator object, so no loops are required.
If called with a single iterator, 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.
1var iterate = require('iterate-iterator'); 2var getIterator = require('es-get-iterator'); 3var assert = require('assert'); 4 5assert.deepEqual(iterate(getIterator('a 💩')), ['a', ' ', '💩']); 6assert.deepEqual(iterate(getIterator([1, 2])), [1, 2]); 7assert.deepEqual(iterate(getIterator(new Set([1, 2]))), [1, 2]); 8assert.deepEqual(iterate(getIterator(new Map([[1, 2], [3, 4]]))), [[1, 2], [3, 4]]); 9 10function assertWithCallback(iterable, expected) { 11 var values = []; 12 var callback = function (x) { values.push(x); }; 13 iterate(iterable, callback); 14 assert.deepEqual(values, expected); 15} 16assertWithCallback(getIterator('a 💩'), ['a', ' ', '💩']); 17assertWithCallback(getIterator([1, 2]), [1, 2]); 18assertWithCallback(getIterator(new Set([1, 2])), [1, 2]); 19assertWithCallback(getIterator(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/26 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