https://github.com/gregros/promise-stuff
Utility functions for promises!
https://github.com/gregros/promise-stuff
async javascript promise typescript utility
Last synced: 27 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-29T08:43:34.000Z (over 2 years ago)
- Last Synced: 2025-04-27T07:05:57.269Z (about 1 month ago)
- Topics: async, javascript, promise, typescript, utility
- Language: TypeScript
- Homepage:
- Size: 385 KB
- Stars: 1
- Watchers: 2
- 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!*[](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`
[](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);