4.1.3 • Published 3 years ago
onions v4.1.3
Onions
Intro
Add function middleware in before or after
Install
$ npm install onions --save
Usage
import onions from 'onions';
const before1 = (next) => (a, b) => next(a + 1, b + 1);
const before2 = (next) => async (a, b) => {
await Promise.resolve();
next(a + 1, b + 1);
};
const before3 = (next) => (a, b) => next(a + 1, b + 1);
const after = (next) => (...args) => {
console.log('After');
next(...args);
};
async function target(a, b) {
const result = a + b;
await Promise.resolve();
return result;
}
(async () => {
const newTarget = onions(target, [before1, before2, before3], after) // after or [after]
await newTarget(1, 2); // 9
})();
> 9
> After
4.1.3
3 years ago
4.1.2
3 years ago
4.1.1
3 years ago
4.1.0
3 years ago
4.0.4
3 years ago
4.0.3
3 years ago
4.0.1
3 years ago
4.0.2
3 years ago
4.0.0
3 years ago
3.1.2
3 years ago
3.1.1
4 years ago
3.1.0
4 years ago
3.0.0
4 years ago
2.1.0
4 years ago
2.0.0
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago