0.0.64 • Published 11 months ago

kaze v0.0.64

Weekly downloads
2
License
LGPL-3.0-or-later
Repository
github
Last release
11 months ago

code style: prettier

kaze

asynchronous flow control lib implemented in a promise way

install

npm i kaze

terminology

AsyncFunc

A function which return a promise.

assertFunc

A specilal AsyncFunc of which the promise will be resolved with a boolean value.

badges

API

waterfall

This function takes an array of AsyncFuncs and excute them in series. Each function pass their results to the next in the array. If any of the functions is rejected, the following functions won't be executed, and the main promise will be immediately rejected as well.

example:

const counter = accumulator => Promise.resolve(accumulator + 1)
let promise = waterfall([counter, counter], 1)
promise.then(data => console.log(data)) // 3

compose

This is similar to waterfall, but it create a function which is a composition of the passed AsyncFuncs. Composing functions f(), g(), and h() would produce the result of f(g(h())). Each function consumes the return value of the function that follows.

example:

const counter = accumulator => Promise.resolve(accumulator + 1)
let newFunc = compose([counter, counter])
console.log(newFunc(1)) // 3

whilst

It excute iteratee repeately, while test returns true. The return promise will be resolved right after the loop end.

example:

const test = () => Promise.resolve()
const counter = accumulator => Promise.resolve(accumulator + 1)
let newFunc = compose([counter, counter])
console.log(newFunc(1)) // 3
0.0.64

11 months ago

0.0.63

1 year ago

0.0.62

2 years ago

0.0.60

2 years ago

0.0.61

2 years ago

0.0.58

2 years ago

0.0.59

2 years ago

0.0.55

5 years ago

0.0.36

5 years ago

0.0.33

5 years ago

0.0.32

5 years ago

0.0.31

5 years ago

0.0.30

5 years ago

0.0.29

5 years ago

0.0.28

5 years ago