/function/whenTrue
stdRuns the given function only when the condition is exactly true.
Type signature
(action: (...xs: unknown[]) => unknown) => (...args: unknown[]) => unknown
Examples
whenTrue((x) => console.log(x))(
false,
);
when((x) => x > 0)((x) =>
console.log(x),
)(true);
Try in REPL
Questions
- How to run a function only if its argument is true?
- How to execute function only if a variable is true?