fish
The (>=>)
and (<=<)
operators in JavaScript. Kinda.
Install
npm install fish-operator
Usage
The first parameter of these functions is the string
or Symbol
key of the bind
method for the objects returned by the functions to compose. A bind method will have the signature bind :: (A -> m<B>) -> m<B>
for a given m<A>
. For Promises, this will be the then
method so you will pass in 'then'
as the first parameter. The following examples show this idea using Promise-returning functions:
const compose pipe = ; const f = Promise;const g = Promise; const h = f g;await ;// <- 21 const j = f g;await ;// <- 22
In the real world, you would probably use these functions like this:
const pipe = ;const pipeP = ;const prop = objkey; // Fictitious Promise-returning API functions...const getUserById = Promise;const getJobById = Promise; const getJobByUserId = ;await ;// <- 'Rattlesnake Groomer'
Each function accepts any number of functions that return either a value or an object with a method that matches the bindKey
parameter given.
License
WTFPL