promisu
promisu is a JavaScript lib for functional promise with the following operators: Map, Filter, Reduce, Scan, Every, Some, Few, Finally, All, Race, Try, WaitFor, Queue, Debounce, Throttle.
Examples
; const asyncTask = { return { }}; const testPromisuQueue = { // PromisuQueue console; const promisuQueue = PromisuQueue; promisuQueue; promisuQueue; promisuQueue; // async task 1000 Done // async task 3000 Done // async task 2000/4000 Done } const testPromisuAll = { // PromisuAll console; // PromisuAll done [ 2000, 4000 ] } const testPromisuRace = { // PromisuRace console; // PromisuRace done 1000 } const testPromisuEvery = { // PromisuEvery console; const testFn = x > 1000; // PromisuEvery done true } const testPromisuSome = { // PromisuSome console; const testFn = x > 2000; // PromisuSome done true } const testPromisuFew = { // PromisuFew console; // PromisuFew done [ 3000, 1000 ] } const testPromisuMap = { // PromisuMap console; const mapFn = { } // PromisuMap done [ 2001, 3001, 1001 ] } const testPromisuFilter = { // PromisuFilter console; const filterFn = { } // PromisuFilter done [ 2000, 3000 ] } const testPromisuReduce = { // PromisuReduce console; const reduceFn = { } // PromisuReduce done 6000 } const testPromisuScan = { // PromisuScan console; const scanFn = { } // PromisuScan done [ 0, 2000, 5000, 6000 ] } const testPromisuWaitFor = { // PromisuWaitFor console; const waitFn = { } // PromisuWaitFor done } const testPromisuFinally = { // PromisuFinally console; // TODO } const testPromisuTry = { // PromisuTry console; // TODO } const testPromisuDebounce = { // PromisuDebounce console; // TODO } const testPromisuThrottle = { // PromisuThrottle console; // TODO } const testArr = testPromisuQueue testPromisuAll testPromisuRace testPromisuEvery testPromisuSome testPromisuFew testPromisuMap testPromisuFilter testPromisuReduce testPromisuScan testPromisuWaitFor testPromisuFinally testPromisuTry testPromisuDebounce testPromisuThrottle const run = async { for let next of testArr await }
Installation
npm install --save promisu
Usage
You can import one or multiple operators from promisu
:
;// orconst PromisuAll PromisuMap PromisuEvery PromisuFew PromisuFilter PromisuFinally PromisuQueue PromisuRace PromisuReduce PromisuSome PromisuTry PromisuWaitFor PromisuScan PromisuDebounce PromisuThrottle } = ;