Skip to main content

Function: isEmpty()

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

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

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.