Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kozhevnikov/proxymise
Chainable Promise Proxy
https://github.com/kozhevnikov/proxymise
javascript promise proxy
Last synced: 29 days ago
JSON representation
Chainable Promise Proxy
- Host: GitHub
- URL: https://github.com/kozhevnikov/proxymise
- Owner: kozhevnikov
- License: mit
- Created: 2018-07-13T00:26:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-05T08:24:32.000Z (about 2 years ago)
- Last Synced: 2024-10-02T23:13:42.043Z (2 months ago)
- Topics: javascript, promise, proxy
- Language: JavaScript
- Size: 177 KB
- Stars: 556
- Watchers: 11
- Forks: 20
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nodejs-keynotes - proxymise
- awesome-list - proxymise
README
# Proxymise
[![npm](https://img.shields.io/npm/v/proxymise.svg)](https://www.npmjs.com/package/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.[Proxy]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
[Promises]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise## Use
```shell
npm i proxymise
``````javascript
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
- [Fetch and parse JSON](https://github.com/kozhevnikov/proxymise/blob/master/test/fetch.test.js)
- [Amazon DynamoDB get item](https://github.com/kozhevnikov/proxymise/blob/master/test/dynamodb.test.js)
- [Selenium WebDriverJS and Page Objects](https://github.com/kozhevnikov/proxymise/blob/master/test/selenium.test.js)## Performance
Proxymised [benchmark] with 10000 iterations is practically as performant as the non-proxymised one.
[benchmark]: https://github.com/kozhevnikov/proxymise/blob/master/test/benchmark.js
```shell
node test/benchmark.js
with proxymise: 3907.582ms
without proxymise: 3762.375ms
```