promise-stuff
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

Promise-stuff

Because promises can use a lot more stuff!

npm

API

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

This is a small package designed to integrate promsise-stuff into the native ES6 promise by doing:

PromiseStuff.extendExisting(Promise);

Package Sidebar

Install

npm i promise-stuff

Weekly Downloads

25

Version

0.4.1

License

MIT

Unpacked Size

105 kB

Total Files

36

Last publish

Collaborators

  • gregros