Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iterall

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iterall

Minimal zero-dependency utilities for using JavaScript Iterables in all environments.

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9M
decreased by-0.28%
Maintainers
1
Weekly downloads
 
Created

What is iterall?

The iterall package provides utilities for creating and manipulating JavaScript iterables and iterators. It allows for easy handling of synchronous iteration patterns, which are part of the ECMAScript 2015 (ES6) specification. The package includes functions to check for iterable objects, create custom iterators, and iterate over collections in a manner that is compatible with both ES6 and legacy JavaScript environments.

What are iterall's main functionalities?

isIterable

Checks if an object is an iterable. This is useful for determining if you can use a `for...of` loop or other iteration mechanisms on an object.

const { isIterable } = require('iterall');

const array = [1, 2, 3];
const isItIterable = isIterable(array); // true

isIterator

Determines if an object is an iterator. This can be used to check if an object conforms to the iterator protocol before attempting to iterate over its values.

const { isIterator } = require('iterall');

const iterator = array[Symbol.iterator]();
const isItIterator = isIterator(iterator); // true

createIterator

Creates an iterator from an iterable object. This function allows you to manually control the iteration process, calling `next()` to get values one at a time.

const { createIterator } = require('iterall');

const array = [1, 2, 3];
const iterator = createIterator(array);
iterator.next(); // { value: 1, done: false }

forEach

Iterates over each value in an iterable, calling a provided function on every element. This is similar to `Array.prototype.forEach` but works with any iterable object.

const { forEach } = require('iterall');

forEach(array, (value) => console.log(value)); // logs 1, 2, 3

getIterator

Retrieves an iterator from an iterable object. This is a convenience function that handles the presence of the `Symbol.iterator` method on the object.

const { getIterator } = require('iterall');

const iterator = getIterator(array);
iterator.next(); // { value: 1, done: false }

getIteratorMethod

Gets the iterator method of an iterable object. This can be used to access the default iterator of an object without directly invoking it.

const { getIteratorMethod } = require('iterall');

const method = getIteratorMethod(array);
const iterator = method.call(array);
iterator.next(); // { value: 1, done: false }

Other packages similar to iterall

Keywords

FAQs

Package last updated on 03 Jan 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc