28
GitHub - kozhevnikov/proxymise: Chainable Promise Proxy
source link: https://github.com/kozhevnikov/proxymise
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
Proxymise
Chainable Promise Proxy
Lightweight ES6 Proxy for Promises with no additional dependencies. Proxymise allows for method
and property chaining without need for intermediate then()
or await
for cleaner and simpler code.
Use
npm i proxymise
const proxymise = require('proxymise'); // Instead of thens foo.then(value => value.bar()) .then(value => value.baz()) .then(value => value.qux) .then(value => console.log(value)); // Instead of awaits const value1 = await foo; const value2 = await value1.bar(); const value3 = await value2.baz(); const value4 = await value3.qux; console.log(value4); // Use proxymise const value = await proxymise(foo).bar().baz().qux; console.log(value);
Practical Examples
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK