Skip to content

function

Contains utility functions and types for working with functions.

FunctionDescription
cloneFunctionClone 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.
createFunctionCreates a function from the provided parameters.
getFunctionExpressionStringConverts 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 .
noopA function that does nothing.
noopAsyncA function that does nothing.
omitAsyncReturnTypeMakes an async function that calls the original async function with the provided arguments and omits the return value.
omitReturnTypeMakes a function that calls the original function with the provided arguments and omits the return value.
TypeDescription
GenericAsyncFunctionRepresents a generic async function.
GenericAsyncVoidFunctionRepresents a generic async void function.
GenericFunctionRepresents a generic function.
GenericPromisableFunctionRepresents a generic promisable function.
GenericPromisableVoidFunctionRepresents a generic promisable void function.
GenericVoidFunctionRepresents a generic void function.
VariableDescription
noopAsyncSingletonPromiseA singleton no-op promise.