** Executes a function only when a condition is met.**
const logIfPositive = when((x: number) => x > 0, console.log);logIfPositive(5); // Logs: 5logIfPositive(-2); // (No output) Copy
const logIfPositive = when((x: number) => x > 0, console.log);logIfPositive(5); // Logs: 5logIfPositive(-2); // (No output)
The input type.
Condition to check.
Function to execute when the condition is true.
** Executes a function only when a condition is met.**
Example