UNPKG

1.79 kBTypeScriptView Raw
1/** Returns whether the value is a function. Acts as a type guard. */
2export declare function isFunction(value: any): value is Function;
3/**
4 * Safely invoke the function with the given arguments, if it is indeed a
5 * function, and return its value. Otherwise, return undefined.
6 *
7 * @deprecated use TypeScript 3.7+ optional call operator func?.()
8 */
9export declare function safeInvoke<R>(func: (() => R) | undefined): R | undefined;
10export declare function safeInvoke<A, R>(func: ((arg1: A) => R) | undefined, arg1: A): R | undefined;
11export declare function safeInvoke<A, B, R>(func: ((arg1: A, arg2: B) => R) | undefined, arg1: A, arg2: B): R | undefined;
12export declare function safeInvoke<A, B, C, R>(func: ((arg1: A, arg2: B, arg3: C) => R) | undefined, arg1: A, arg2: B, arg3: C): R | undefined;
13export declare function safeInvoke<A, B, C, D, R>(func: ((arg1: A, arg2: B, arg3: C, arg4: D) => R) | undefined, arg1: A, arg2: B, arg3: C, arg4: D): R | undefined;
14/**
15 * Safely invoke the provided entity if it is a function; otherwise, return the
16 * entity itself.
17 *
18 * @deprecated use TypeScript 3.7+ optional call operator func?.()
19 */
20export declare function safeInvokeOrValue<R>(funcOrValue: (() => R) | R | undefined): R;
21export declare function safeInvokeOrValue<A, R>(funcOrValue: ((arg1: A) => R) | R | undefined, arg1: A): R;
22export declare function safeInvokeOrValue<A, B, R>(funcOrValue: ((arg1: A, arg2: B) => R) | R | undefined, arg1: A, arg2: B): R;
23export declare function safeInvokeOrValue<A, B, C, R>(funcOrValue: ((arg1: A, arg2: B, arg3: C) => R) | R | undefined, arg1: A, arg2: B, arg3: C): R;
24export declare function safeInvokeOrValue<A, B, C, D, R>(funcOrValue: ((arg1: A, arg2: B, arg3: C, arg4: D) => R) | R | undefined, arg1: A, arg2: B, arg3: C, arg4: D): R;