giantdb
Version:
Large object database in native JavaScript, with encryption support
45 lines (44 loc) • 1.49 kB
TypeScript
/**
* A set of string ids, which can be lazy-loaded and iterated over.
*/
export declare class IdSet {
private _backingSet;
private readonly _getBackingSet;
/**
* Construct a new IdSet. The load function is used to obtain the initial list
* of ids.
*
* @param loadFunction A function returning or promising an array of strings, the initial ids.
*/
constructor(loadFunction: () => readonly string[] | Promise<readonly string[]>);
/**
* Add the given id to the set.
*
* @param id The id to add.
* @returns A Promise that is resolved when done.
*/
add(id: string): Promise<void>;
/**
* Remove the given id from the set.
*
* @param id The id to remove.
* @returns A Promise that is resolved when done.
*/
remove(id: string): Promise<void>;
/**
* Determine whether the given id is contained in this set.
*
* @param id The id to check.
* @returns A Promise for whether the id is in this set.
*/
includes(id: string): Promise<boolean>;
/**
* Iterate over all ids in this set. Iteration happens sequentially. If the
* callback returns a Promise or thenable, it is awaited before continuing with
* the next element.
*
* @param callbackFn The function to execute for each set element.
* @returns A Promise that is resolved when iteration is finished.
*/
each(callbackFn: (id: string) => any): Promise<void>;
}