Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
iterate-iterator
Advanced tools
Iterate any JS iterator. Works robustly in all environments, all versions.
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.
var iterate = require('iterate-iterator');
var getIterator = require('es-get-iterator');
var assert = require('assert');
assert.deepEqual(iterate(getIterator('a 💩')), ['a', ' ', '💩']);
assert.deepEqual(iterate(getIterator([1, 2])), [1, 2]);
assert.deepEqual(iterate(getIterator(new Set([1, 2]))), [1, 2]);
assert.deepEqual(iterate(getIterator(new Map([[1, 2], [3, 4]]))), [[1, 2], [3, 4]]);
function assertWithCallback(iterable, expected) {
var values = [];
var callback = function (x) { values.push(x); };
iterate(iterable, callback);
assert.deepEqual(values, expected);
}
assertWithCallback(getIterator('a 💩'), ['a', ' ', '💩']);
assertWithCallback(getIterator([1, 2]), [1, 2]);
assertWithCallback(getIterator(new Set([1, 2])), [1, 2]);
assertWithCallback(getIterator(new Map([[1, 2], [3, 4]])), [[1, 2], [3, 4]]);
Simply clone the repo, npm install
, and run npm test
v1.0.0 - 2020-01-18
f8a3f99
589f745
f380dd6
b59c8b1
267d24e
auto-changelog
31831fa
2462c16
npm run lint
89235a5
a3bba74
ab1d122
safe-publish-latest
daa34af
FAQs
Iterate any JS iterator. Works robustly in all environments, all versions.
The npm package iterate-iterator receives a total of 1,817,386 weekly downloads. As such, iterate-iterator popularity was classified as popular.
We found that iterate-iterator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.