项目
在 GitHub 查看
kozhevnikov/proxymise
关于
可链式调用的 Promise 代理
系统与基础设施实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
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
Performance
Proxymised benchmark with 10000 iterations is practically as performant as the non-proxymised one.
node test/benchmark.js
with proxymise: 3907.582ms
without proxymise: 3762.375ms
探索相关项目
加载中…