-
-
Notifications
You must be signed in to change notification settings - Fork 0
function
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isFunction<T extends FunctionOrConstructor>(
it: T | unknowns,
): it is FunctionOrConstructor<any, any, any> extends T ? Function : T;Check if the given value is a function.
| Name | Info |
|---|---|
it |
The value to check. |
true if the value is a function, false otherwise.
Standard
import { isFunction } from "jsr:@nick/is/function";
console.log(isFunction(() => {})); // true
console.log(isFunction(function () {})); // true
console.log(isFunction(class {})); // true
console.log(isFunction(new Function())); // true
console.log(isFunction({})); // false
console.log(isFunction(1)); // falsefunction isFunction<T = any, A extends readonly any[] = any[]>(
it: Fn<T, A> | unknowns,
): it is Fn<T, A>;function isFunction<T = any, A extends readonly any[] = any[], R = any>(
it: ThisFn<T, A, R> | unknowns,
): it is ThisFn<T, A, R>;function isFunction(it: unknown): it is Function;function isFunction(it: unknown): it is FunctionOrConstructor;export type Fn<T = any, A extends readonly any[] = any[]> = (...args: A) => T;-
T(default:any) -
Aextendsreadonly any[](default:any[])
export type FunctionOrConstructor<
T = any,
A extends readonly any[] = any[],
R = void,
> = Constructor<R, A> | Fn<R, A> | ThisFn<T, A, R> | Function;-
T(default:any) -
Aextendsreadonly any[](default:any[]) -
R(default:void)
export type ThisFn<T = any, A extends readonly any[] = any[], R = any> = (
this: T,
...args: A
) => R;-
T(default:any) -
Aextendsreadonly any[](default:any[]) -
R(default:any)