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

3.0.0 • Public • Published

is-empty-iterable

Check if an Iterable is empty

More efficient than Array.from(iterable).length, as it only iterates the first item, which can make a big difference for dynamic iterators, like a Generator doing an expensive operation.

Install

$ npm install is-empty-iterable

Usage

import isEmptyIterable from 'is-empty-iterable';

isEmptyIterable([]);
//=> true

isEmptyIterable(new Set([1, 2]));
//=> false

API

isEmptyIterable(iterable)

Returns a boolean.

iterable

Type: Iterable

/is-empty-iterable/

    Package Sidebar

    Install

    npm i is-empty-iterable

    Weekly Downloads

    3,161

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    2.82 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus