negate es-toolkit
Creates a new function that inverts the return value of a function that returns true or false.
Usage
negate(func)
Use negate when you want to invert the result of a function that returns true or false.
This is useful for inverting conditional functions or filtering logic. For example, you can turn a function that finds even numbers into a function that finds odd numbers.
You can also invert complex conditional functions.
Parameters
A function that returns a boolean value.
Returns
Returns a new function that accepts the same arguments as the original function but returns the opposite boolean value.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.