@naturalcycles/js-lib
Version:
Standard library for universal (browser + Node.js) javascript
21 lines (20 loc) • 547 B
TypeScript
/**
* Like Set, but serializes to JSON as an array.
*
* Fixes the "issue" of stock Set being json-serialized as `{}`.
*
* @experimental
*/
export declare class Set2<T = any> extends Set<T> {
static of<T>(items?: Iterable<T> | null): Set2<T>;
/**
* Like .add(), but allows to add multiple items at once.
* Mutates the Set, but also returns it conveniently.
*/
addMany(items: Iterable<T>): this;
first(): T;
firstOrUndefined(): T | undefined;
toArray(): T[];
toJSON(): T[];
toString(): string;
}