Skip to content

function

Contains utility functions and types for working with functions.

Function Description
cloneFunction Clone a function by creating a new function that calls the original function. This is useful for creating a new instance of a function that has the same behavior but is not strictly equal to the original function.
createFunction Creates a function from the provided parameters.
getFunctionExpressionString Converts a function into a string that is a valid function expression. Function.prototype.toString() on a shorthand method like \{ fn() \{\} \} returns "fn() \{\}", which is not a valid expression. This helper detects that form and prefixes it with function .
noop A function that does nothing.
noopAsync A function that does nothing.
omitAsyncReturnType Makes an async function that calls the original async function with the provided arguments and omits the return value.
omitReturnType Makes a function that calls the original function with the provided arguments and omits the return value.
Type Description
GenericAsyncFunction Represents a generic async function.
GenericAsyncVoidFunction Represents a generic async void function.
GenericFunction Represents a generic function.
GenericPromisableFunction Represents a generic promisable function.
GenericPromisableVoidFunction Represents a generic promisable void function.
GenericVoidFunction Represents a generic void function.
Variable Description
noopAsyncSingletonPromise A singleton no-op promise.