proxymise

Chainable Promise Proxy

Proxymise

Chainable Promise Proxy.

Lightweight ES6 Proxyfor Promiseswith no additional dependencies. Proxymise allows for method and property chaining without need for intermediate then()or awaitfor 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 benchmarkwith 10000 iterations is practically as performant as the non-proxymised one.

node test/benchmark.js 
with proxymise: 3907.582ms
without proxymise: 3762.375ms

Repository

https://github.com/kozhevnikov/proxymise


上一篇:koogn
下一篇:to-json-schema

相关推荐

暂无相关文章

官方社区

扫码加入 JavaScript 社区