mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-01 02:33:54 +03:00
27 lines
501 B
Markdown
27 lines
501 B
Markdown
# negate
|
|
|
|
Creates a function that negates the result of the predicate function.
|
|
|
|
## Signature
|
|
|
|
```typescript
|
|
function negate<F extends (...args: unknown[]) => boolean>(func: F): F;
|
|
```
|
|
|
|
### Parameters
|
|
|
|
- `func` (`F extends (args: ...Parameters) => unknown`): The function to negate.
|
|
|
|
### Returns
|
|
|
|
- (`F`): Returns the new negated function.
|
|
|
|
## Examples
|
|
|
|
```typescript
|
|
import { negate } from 'es-toolkit/function';
|
|
|
|
negate(() => true)(); // returns 'false'
|
|
negate(() => false)(); // returns 'true'
|
|
```
|