Skip to main content

Function: isEmpty()

isEmpty<ElementType>(iterable: IterableResolvable<ElementType>): boolean

Advances the iterable once, returning true if it's exhausted and false otherwise.

Type parameters

Type parameter
ElementType

Parameters

ParameterTypeDescription
iterableIterableResolvable<ElementType>The iterator to check for emptiness.

Returns

boolean

true if the iterator is empty; otherwise, false.

Example

import { isEmpty } from '@sapphire/iterator-utilities';

console.log(isEmpty([]));
// Output: true

console.log(isEmpty([1, 2, 3, 4, 5]));
// Output: false

Remarks

This function consumes the first value of the iterator.

Source

projects/utilities/packages/iterator-utilities/src/lib/isEmpty.ts:24