UNPKG

functionalscript

Version:

FunctionalScript is a purely functional subset of JavaScript

20 lines (19 loc) 442 B
/** * A postfix compose function. */ export const compose = g => f => x => f(g(x)); /** * A generic identity function. */ export const identity = value => value; /** * Flips the arguments of a curried function. */ export const flip = f => b => a => f(a)(b); /** * Creates an `Fn` instance from a function, enabling chaining of transformations. */ export const fn = (result) => ({ result, then: g => fn(compose(result)(g)) });