typedash
Version:
modern, type-safe collection of utility functions
22 lines (21 loc) • 543 B
JavaScript
//#region src/functions/negate/negate.ts
/**
* Returns a new function that negates the result of the input function.
* @param func The input function to negate.
* @returns A new function that negates the result of the input function.
* @example
* ```ts
* const isEven = (num: number) => num % 2 === 0;
* const isOdd = negate(isEven);
* isOdd(1); // true
* isOdd(2); // false
* ```
*/
function negate(func) {
return (...args) => {
return !func(...args);
};
}
//#endregion
export { negate as t };
//# sourceMappingURL=negate-B3yzC5pg.js.map