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.2 - 2021-10-01
13a9d00
15d4556
node/install
instead of node/run
; use codecov
action a23decd
nyc
on all tests; use tape
runner 86adda1
9c44f28
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, es-get-iterator
, object-inspect
, tape
7887af7
eslint
, @ljharb/eslint-config
, auto-changelog
, object-inspect
, tape
21975ca
eslint
, @ljharb/eslint-config
, aud
, es-get-iterator
, object-inspect
, tape
a42d8cd
a23d108
dc38174
@ljharb/eslint-config
, es-get-iterator
970e212
1a41785
pull_request_target
event 9e5bcbf
aud
, auto-changelog
63f0b43
auto-changelog
, tape
2186bf5
package.json
to "exports" 97a1ac2
prepublishOnly
, for npm 7+ b35c088
15f9f7c
funding
field ab52815
tape
d044397
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.