You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

es-get-iterator

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-get-iterator

Get an iterator for any JS language value. Works robustly across all environments, all versions.

1.1.3
latest
Source
npmnpm
Version published
Weekly downloads
12M
-0.9%
Maintainers
1
Weekly downloads
 
Created

What is es-get-iterator?

The es-get-iterator package is a utility for retrieving an iterator from a given object, array, string, or other iterable types in JavaScript. It abstracts away the differences between various iterable protocols and provides a unified way to iterate over values in different types of collections.

What are es-get-iterator's main functionalities?

Getting an iterator from an array

This feature demonstrates how to retrieve an iterator from an array and use it to access the first element.

const getIterator = require('es-get-iterator');
const array = [1, 2, 3];
const iterator = getIterator(array);
console.log(iterator.next().value); // 1

Getting an iterator from a string

This feature shows how to get an iterator from a string to iterate over its characters.

const getIterator = require('es-get-iterator');
const string = 'hello';
const iterator = getIterator(string);
console.log(iterator.next().value); // 'h'

Getting an iterator from a Map

This example demonstrates retrieving an iterator from a Map object to iterate over its key-value pairs.

const getIterator = require('es-get-iterator');
const map = new Map([[1, 'one'], [2, 'two']]);
const iterator = getIterator(map);
console.log(iterator.next().value); // [1, 'one']

Other packages similar to es-get-iterator

Keywords

iterator

FAQs

Package last updated on 13 Jan 2023

Did you know?

Socket

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.

Install

Related posts