1.1.0 • Published 8 years ago

wee-promise v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

WeePromise

An ultra light (<1k minified / gzipped) Promises / A+ implementation.

travis-ci

Installation

npm i wee-promise --save

Usage

WeePromise supports both deferred and resolver patterns:

function asDeferred() {
	const deferred = new WeePromise();
	doSomethingAsync(deferred.resolve);
	return deferred;
}

function asResolver() {
	return new WeePromise((resolve) => {
		doSomethingAsync(resolve);
	});
}

as well as ES6-style all and race methods:

const arr = getCollectionOfPromises();

WeePromise.all(arr).then((result) => {
	// result is an array of all of the promise values in arr.
});

WeePromise.race(arr).then((result) => {
	// result is the value of the first resolved promise in arr.
});

and can be extended to create objects that behave as A+ compliant promises:

class Gnarly extends WeePromise {
	// ...
}

If you want to change WeePromise's async provider, just override WeePromise.async:

WeePromise.async = (cb) => {
	const img = new Image();
	img.onload = img.onerror = cb;
	img.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
};

Build & Test

npm i && npm run build
1.1.0

8 years ago

1.0.8

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.2.0

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago