everyflow
v0.0.1
Published
flow like Array.prototype.every()
Downloads
5
Readme
everyflow ·
🧵 Chaining like Array.prototype.every()
Installation
npm install everyflow
Usage
import everyFlow from 'everyflow';
everyFlow(true, true).then(() => {
// resolve
});
everyFlow(true, false).catch(() => {
// reject
});
everyFlow(true, () => true).catch(() => {
// resolve
});
everyFlow(true, () => false).catch(() => {
// reject
});
everyFlow(() => Promise.resolve(true)).then(() => {
// resolve
});
everyFlow(() => Promise.resolve(false)).catch(() => {
// reject
});
everyFlow(async () => await asyncFn());
everyFlow(async (setState) => {
const result = await asyncFn();
setState({
step1: result,
});
return true;
}).then(state => {
// get state on resolve
});
everyFlow(async (setState) => {
const result = await asyncFn();
setState({
step1: result,
});
return false;
}).catch(state => {
// get state on reject
});