Skip to main content

abstract class EmptyBase

A shared base class for empty collection instances. It implements the common Collection API for the empty case and is reused across different collection types. All mutating-style operations return this, and all querying operations return the empty value for their respective type.

sealed

Properties​

_NonEmptyType​

undocumented

Definition​

readonly _NonEmptyType: unknown;

isEmpty​

Returns true since the collection is empty.

Definition​

get isEmpty(): true;

length​

Returns 0 for the length of the collection.

Definition​

get length(): 0;

size​

Returns 0 for the size of the collection.

Definition​

get size(): 0;

Methods​

[Symbol.iterator]​

Returns an empty iterator.

Definition​

[Symbol.iterator](): FastIterator<any>;

assumeNonEmpty​

Throws a RimbuError.EmptyCollectionAssumedNonEmptyError, since the collection is empty.

Definition​

assumeNonEmpty(): never;

throws

RimbuError.EmptyCollectionAssumedNonEmptyError

filter​

Returns this, since filtering an empty collection is still empty.

Definition​

filter(): any;

forEach​

Performs no action, since there are no elements.

Definition​

forEach(): void;

nonEmpty​

Returns false, keeping the type narrowed to the empty variant.

Definition​

nonEmpty(): this is this['_NonEmptyType'];

remove​

Returns this, since removing from an empty collection has no effect.

Definition​

remove(): any;

stream​

Returns an empty Stream.

Definition​

stream(): Stream<any>;

toArray​

Returns an empty array.

Definition​

toArray(): [];