TypeScript
when lets you declaratively gate side-effects, computations, or constant values behind one or more conditions (booleans or predicates). If all conditions are truthy, your callback runs (or your constant is returned). Otherwise it returns false.
type Condition<Args extends unknown[]> = boolean | ((...args: Args) => boolean);
type Nested<T> = T | ReadonlyArray<Nested<T>>;
export const when =