space-lift
Version:
TypeScript Array, Object, Map, Set, Union, Enum utils
54 lines (53 loc) • 1.91 kB
TypeScript
import type { Pipe } from './lift';
/** A Set wrapper providing extra functionalities and more chaining opportunities */
export declare class SetWrapper<T, S extends ReadonlySet<T>> {
private _value;
constructor(_value: S);
private _isLiftWrapper;
value(): S;
private _clone;
/**
* Adds a new value to this Set.
*/
add(item: T): this;
/**
* Adds all items from the passed iterable to this Set.
*/
addAll(items: Iterable<T>): this;
/**
* Deletes one value from this Set.
*/
delete(item: T): this;
/**
* Maps this Set's items, unless void or undefined is returned, in which case the item is filtered.
* This is effectively a `filter` + `map` combined in one.
*/
collect<B>(iterator: (item: T) => B | void | undefined): SetWrapper<B, SetOf<S, B>>;
/**
* Filters this Set's items by aplying a predicate to all values and refine its type.
*/
filter<B extends T>(predicate: (item: T) => item is B): SetWrapper<B, SetOf<S, B>>;
/**
* Filters this Set's items.
*/
filter(predicate: (item: T) => boolean): SetWrapper<T, S>;
/**
* Returns the Set of all items of this Set that are also found in the passed Set.
*/
intersection(other: ReadonlySet<T>): SetWrapper<T, S>;
/**
* Returns the Set of all items of this Set that are not found in the passed Set.
*/
difference(other: ReadonlySet<T>): SetWrapper<T, S>;
/**
* Transforms this Set into an Array. The insertion order is kept.
*/
toArray(): import("./array").ArrayWrapper<T[]>;
/**
* Pipes this Set with an arbitrary transformation function.
*/
pipe: typeof import("./lift").pipe;
}
export declare function setSetPipe(_pipe: Pipe): void;
declare type SetOf<T extends ReadonlySet<unknown>, ITEM> = T extends Set<any> ? Set<ITEM> : ReadonlySet<ITEM>;
export {};