shelving
Version:
Toolkit for using data in JavaScript.
29 lines (28 loc) • 1.27 kB
TypeScript
import type { ImmutableArray, PossibleArray } from "../util/array.js";
import type { AnyCaller } from "../util/function.js";
import { BusyStore } from "./BusyStore.js";
/** Store an array. */
export declare class ArrayStore<T> extends BusyStore<ImmutableArray<T>, PossibleArray<T>> implements Iterable<T> {
constructor(value?: PossibleArray<T>);
protected _convert(input: PossibleArray<T>, caller: AnyCaller): ImmutableArray<T>;
/** Get the first item in this store or `null` if this query has no items. */
get optionalFirst(): T | undefined;
/** Get the last item in this store or `null` if this query has no items. */
get optionalLast(): T | undefined;
/** Get the first item in this store. */
get first(): T;
/** Get the last item in this store. */
get last(): T;
/** Does the document have at least one result. */
get exists(): boolean;
/** Get the length of the current value of this store. */
get count(): number;
/** Add items to this array. */
add(...items: T[]): void;
/** Remove items from this array. */
delete(...items: T[]): void;
/** Toggle items in this array. */
toggle(...items: T[]): void;
/** Iterate over the items. */
[Symbol.iterator](): Iterator<T, void>;
}