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[]): Nullable<U> {}

Examples

bind(undefined, f)     // undefined
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