threading
A clojure-inspired utility for threading arbitrary data into the first or last argument of a sequence of functions
Motivation
In order to compose function operations on arbitrary data, you have to nest functions
;
The legibility of the example decreases as the number of functions increase.
Example Usage
Thread-first
Apply the initial & resulting values of the function list to the first argument of the function.
Simply provide an initial value then the functions you'd like to compose on the value.
; const value = ; ;
To use with a function that should already have a value you can pass an array containing the function and the other arguments.
; const value = ; ;
Thread-last
Apply the initial & resulting values of the function list to the last argument of the function.
Simply provide an initial value then the functions you'd like to compose on the value.
; const value = ; ;
To use with a function that should already have a value you can pass an array containing the function and the other arguments.
; const value = ; ;