UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

22 lines 642 B
//#region src/set/addOrThrow.d.ts /** * `addOrThrow(target, value)` * * Adds a `value` to the `target` set and returns a new set. If the value already exists in the set, throws an error. * * ```ts * addOrThrow(new Set([1, 2]), 3); // Set([1, 2, 3]) * addOrThrow(new Set([1, 2]), 2); // throws FnError * ``` * * ```ts * pipe(new Set([1, 2]), addOrThrow(3)); // Set([1, 2, 3]) * pipe(new Set([1, 2]), addOrThrow(2)); // throws FnError * ``` */ declare const addOrThrow: { <T>(value: NoInfer<T>): (target: ReadonlySet<T>) => Set<T>; <T>(target: ReadonlySet<T>, value: NoInfer<T>): Set<T>; }; //#endregion export { addOrThrow };