Skip to content

PURISTA API


PURISTA API / @purista/core / safeBind

Function: safeBind()

safeBind<ThisType, Args, ReturnType>(fn, thisArg): (...args) => ReturnType

Defined in: helper/safeBind.impl.ts:13

Bind this argument like regular .bind(thisArg), but keeps the typescript types in result

Type Parameters

ThisType

ThisType

Args

Args extends unknown[]

ReturnType

ReturnType

Parameters

fn

(this, ...args) => ReturnType

The function

thisArg

ThisType

Returns

(...args): ReturnType

Parameters

args

...Args

Returns

ReturnType

Example

typescript
const functionWithThisSet = safeBind(fn, thisParam)