Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gregros/promise-stuff
Utility functions for promises!
https://github.com/gregros/promise-stuff
async javascript promise typescript utility
Last synced: 9 days ago
JSON representation
Utility functions for promises!
- Host: GitHub
- URL: https://github.com/gregros/promise-stuff
- Owner: GregRos
- License: mit
- Created: 2018-02-09T15:57:48.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-29T08:43:34.000Z (about 2 years ago)
- Last Synced: 2024-12-06T13:08:58.589Z (28 days ago)
- Topics: async, javascript, promise, typescript, utility
- Language: TypeScript
- Homepage:
- Size: 385 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Promise-stuff
*Because promises can use a lot more stuff!*[![npm](https://badge.fury.io/js/promise-stuff.svg )](https://www.npmjs.com/package/promise-stuff)
[API](https://gregros.github.io/promise-stuff/modules/promise_stuff.html)
`promise-stuff` is an awesome little library that adds extra functionality to your promises. It can be installed on any promise implementation or used as a set of static functions.
## Using `promise-stuff`
There are a few ways of using the functions offerred by promise stuff.### As operators
Here is an example:import {Operators} from 'promise-stuff'
let p = new Promise(...);
let result = Operators.lastly(p, x => {
//cleanup
});These operators return a promise of exactly the same type as the original.
### Create a new, derived promise
Create a new promise constructor from an existing one, like a native `Promise` or a different implementation.import {PromiseStuff} from 'promise-stuff';
export MyExtendedPromise = PromiseStuff.deriveNew(Promise);
let newPromise = new MyExtendedPromise(...); //promise constructor
newPromise.lastly(x => {
//cleanup
});### Install on an existing promise
import {PromiseStuff} from 'promise-stuff';
PromiseStuff.extendExisting(Promise);
let pr = new Promise(...);
pr.lastly(x => {
//cleanup
});## Examples
## `Promise-stuff-es6`
[![npm](https://badge.fury.io/js/promise-stuff-es6.svg )](https://www.npmjs.com/package/promise-stuff-es6)This is a small package designed to integrate `promsise-stuff` into the native ES6 promise by doing:
PromiseStuff.extendExisting(Promise);