JSPM

is-iterator

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23
  • Score
    100M100P100Q48060F
  • License MIT

Returns true if an object is an iterator.

Package Exports

  • is-iterator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-iterator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

is-iterator

Returns true if an object is an iterator.

Remember that iterators are not the same thing as iterables! This module only checks for the former.

The ECMAScript standard defines an iterator to be an object with a next() method. To avoid false-positives from objects with next() methods, this module additionally checks to make sure that the iterator is an iterable that points to itself, since this is a characteristic of built-in iterators.

Installation

npm install is-iterator --save

Usage Example

const isIterator = require('is-iterator')

const array = [] // An array is an iterable, but not by itself an iterator

isIterator(array) // false
isIterator(array[Symbol.iterator]()) // true