
Product
Introducing Custom Tabs for Org Alerts
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.
es-get-iterator
Advanced tools
Get an iterator for any JS language value. Works robustly across all environments, all versions.
Get an iterator for any JS language value. Works robustly across all environments, all versions.
In modern engines, value[Symbol.iterator]() is sufficient to produce an iterator (an object with a .next method) for that object. However, older engines:
Symbol 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)es6-shim or core-js or similarThis library attempts to provide an abstraction over all that complexity!
In node v13+, exports is used 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.
@rollup/plugin-replace// rollup.config.js
import replace from '@rollup/plugin-replace';
export default {
...
plugins: [
replace({
"require('has-symbols')()": 'true',
delimiters: ['', '']
})
]
};
var getIterator = require('es-get-iterator');
var assert = require('assert');
var iterator = getIterator('a đź’©');
assert.deepEqual(
[iterator.next(), iterator.next(), iterator.next(), iterator.next()],
[{ done: false, value: 'a' }, { done: false, value: ' ' }, { done: false, value: 'đź’©' }, { done: true, value: undefined }]
);
var iterator = getIterator([1, 2]);
assert.deepEqual(
[iterator.next(), iterator.next(), iterator.next()],
[{ done: false, value: 1 }, { done: false, value: 2 }, { done: true, value: undefined }]
);
var iterator = getIterator(new Set([1, 2]));
assert.deepEqual(
[iterator.next(), iterator.next(), iterator.next()],
[{ done: false, value: 1 }, { done: false, value: 2 }, { done: true, value: undefined }]
);
var iterator = getIterator(new Map([[1, 2], [3, 4]]));
assert.deepEqual(
[iterator.next(), iterator.next(), iterator.next()],
[{ done: false, value: [1, 2] }, { done: false, value: [3, 4] }, { done: true, value: undefined }]
);
Simply clone the repo, npm install, and run npm test
Iterall is a package that provides utilities for working with JavaScript iteration protocols. It offers similar functionality to es-get-iterator by allowing users to work with iterable objects in a consistent manner. However, iterall focuses more on providing a set of utilities for managing iterables rather than just retrieving iterators.
Lodash is a comprehensive utility library that, among its vast array of functionalities, includes methods for iterating over collections such as arrays, objects, and strings. While not exclusively focused on iteration like es-get-iterator, lodash offers more general-purpose utilities that can be used in conjunction with or as an alternative to es-get-iterator for certain use cases.
FAQs
Get an iterator for any JS language value. Works robustly across all environments, all versions.
The npm package es-get-iterator receives a total of 8,626,204 weekly downloads. As such, es-get-iterator popularity was classified as popular.
We found that es-get-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.

Product
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.