bind

Safely pass a nullable value to composition of functions

Import

import { bind } from '@fullstacksjs/toolbox';

Signature

function bind<T, U>(x: Nullable<T>, ...fns: Function[]): U {}

Examples

bind(null,f)           // null
bind(1, f)             // f(1)
bind(2, f, g, h)       // h(g(f(2)))
bind(null, f, g, h, j) // null