You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Space Age reducer abstraction operating on object algebra and monadic tree destructuring.
Usage (ES6)
Install
>> npm install --save astroduct
Import
constB=require('astroduct').B;
Basic - works as a nice chained value reducer
letresult=B(0,(a,b)=>{returna+b}).init(2).blend(2).blend(4).dump();// result == 8
Intermediate - the reducers can be nested
letresult=B({a:B("The first",{map(word){returnword+"duct";},reduce(lastWord,nextWord){return`${lastWord} followed by the ${nextWord}`;}}}),b:B(0,{map(x){returnx+1},reduce(a,b){returnMath.abs(a-b)}})}).init().blend({a:"lava",b:1}).blend({a:"astro",b:2}).dump();//result.a == "The first followed by the lava duct followed by the astroduct"//Challenge! can you figure out what it is//result.b == ?