Skip to content

removeOrThrow

removeOrThrow(target, value)

Removes a value from the target set and returns a new set. If the value doesn't exist in the set, throws an error.

ts
removeOrThrow(new Set([1, 2, 3]), 2); // Set([1, 3])
removeOrThrow(new Set([1, 2, 3]), 4); // throws FnError
ts
pipe(new Set([1, 2, 3]), removeOrThrow(2)); // Set([1, 3])
pipe(new Set([1, 2, 3]), removeOrThrow(4)); // throws FnError