mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 12:05:41 +03:00
880 B
880 B
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
function isFunction(value: unknown): value is (...args: never[]) => unknown;
Parameters
value
(unknown
): The value to check if it is a function.
Returns
(value is (...args: never[]) => unknown
): Returns true
if the value is a function, otherwise false
.
Examples
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