2024-07-21 04:51:09 +03:00
|
|
|
# isFunction
|
|
|
|
|
|
|
|
Checks if `value` is a function.
|
|
|
|
|
|
|
|
This function returns `true` if `value` is a function, and `false` otherwise.
|
|
|
|
|
|
|
|
This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to a function.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
|
|
|
```typescript
|
2024-07-21 04:55:36 +03:00
|
|
|
function isFunction(value: unknown): value is (...args: never[]) => unknown;
|
2024-07-21 04:51:09 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
- `value` (`unknown`): The value to check if it is a function.
|
|
|
|
|
|
|
|
### Returns
|
|
|
|
|
2024-07-21 04:55:36 +03:00
|
|
|
(`value is (...args: never[]) => unknown`): Returns `true` if the value is a function, otherwise `false`.
|
2024-07-21 04:51:09 +03:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
import { isFunction } from 'es-toolkit/predicate';
|
|
|
|
|
|
|
|
console.log(isFunction(Array.prototype.slice)); // true
|
|
|
|
console.log(isFunction(async function () {})); // true
|
|
|
|
console.log(isFunction(function* () {})); // true
|
|
|
|
console.log(isFunction(Proxy)); // true
|
|
|
|
console.log(isFunction(Int8Array)); // true
|
|
|
|
```
|