UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

28 lines (27 loc) 1.16 kB
import type { ImmutableArray } from "../util/array.js"; import type { NONE } from "../util/constants.js"; import { Store } from "./Store.js"; /** Store an array. */ export declare class ArrayStore<T> extends Store<ImmutableArray<T>> implements Iterable<T> { constructor(value?: ImmutableArray<T> | typeof NONE, time?: number); /** 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>; }