Skip to content

cloneFunction<TFunction>

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.

Import:

import { cloneFunction } from 'obsidian-dev-utils/function';

Signature:

function cloneFunction(fn: TFunction): TFunction

Parameters:

ParameterTypeDescription
fnTFunctionThe function to clone.

Returns: TFunction — A new function that has the same behavior as the original function.