pre-get

1.0.8 • Public • Published

pre-get

中文文档

fork proxymise, The information related to the "proxymise" execution stack will be lost, and the pre get is tracked, which greatly improves the availability

npm npm In addition, pre-get also makes proxy proxy more in line with normal thinking

  1.  preget(xx) instanceof Promise // true 
     ;(await preget({a: 1})).a  // 1
  2.  preget(xx).finally()  // Proxymise omits the processing of finally, and preget can be used normally

npm

Chainable Promise Proxy.

Lightweight ES6 Proxy for Promises with no additional dependencies. pre-get allows for method and property chaining without need for intermediate then() or await for cleaner and simpler code.

Use

npm i pre-get
const preget = require('pre-get');

// 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 pre-get
const value = await preget(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

Readme

Keywords

Package Sidebar

Install

npm i pre-get

Weekly Downloads

10

Version

1.0.8

License

MIT

Unpacked Size

14 kB

Total Files

7

Last publish

Collaborators

  • zhanghongen