check-iterable
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Check Iterable

A toolbox to check if an object is iterable, an iterator or a generator, etc.

Install

Node.js

npm i check-iterable

Deno

import * as CheckIterable from "https://deno.land/x/check_iterable/index.js";

API

  • isIterable(obj: any): boolean Checks if the given object is an Iterable (implemented @@iterator).
  • isAsyncIterable(obj: any): boolean Checks if the given object is an AsyncIterable (implemented @@asyncIterator).
  • isIteratorLike(obj: any): boolean Checks if the given object is an IteratorLike (implemented next).
  • isIterableIterator(obj: any): boolean Checks if the given object is an IterableIterator (implemented both @@iterator and next).
  • isAsyncIterableIterator(obj: any): boolean Checks if the given object is an AsyncIterableIterator (implemented both @@asyncIterator and next).
  • isGenerator(obj: any): boolean Checks if the given object is a Generator.
  • isAsyncGenerator(obj: any): boolean Checks if the given object is an AsyncGenerator.

Note:

These functions are designed to test whether an object suits the specifications suggested on MDN in sloppy mode, go to MDN for more details.

Package Sidebar

Install

npm i check-iterable

Weekly Downloads

1,806

Version

1.2.0

License

MIT

Unpacked Size

9.34 kB

Total Files

6

Last publish

Collaborators

  • ayonli