Broody implementation of Promise A+.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Build Status

Broody implementation of Promises/A+.

Whats up?

Promises/A+ logo

Broody promises is a minimalistic lightweight (~1.5KB gzipped) implementation of Promises/A+, with ability to retrieve fulfilled value. Of course, it is possible to do that just when all chain of thens and catchs are resolved synchronous. In other way usage of Broodies did not make any sense to you, because it has no any preferences over already existing and great Promises/A+ libraries.

Getting started

Install with npm

npm install --save broody-promises


	var promise, chain;

	promise = new Promise(function(resolve, reject) {
		// resolve now synchronous
		resolve("my value");

	chain = Promise.sync(function() {
		return promise
			.then(function(value) {
				// again synchronous
				return value + "!";

	chain.result(); // my value!


new Promise(resolver: Function(resolve: Function(value: any), reject: Function(reason: any)))
promise.then(onResolve: Function(value: any), onReject: Function(reason: any)) -> Promise
promise.catch(onReject: Function(reason: any)) -> Promise
promise.finally(anyWay: Function(error: any, value: any)) -> Promise
promise.result() -> any

Returns resolved value.

Throws an error in two cases:

  • target promise is in pending state.
  • target promise was rejected.
promise.isPending() -> Boolean
promise.isFulfilled() -> Boolean
promise.isRejected() -> Boolean

Promise.sync(fn: Function()) -> any

Enters in a new context with given functon, when any new Promise (created synchronously) will have synchronous resolution of onFulfilled and onRejected callbacks in .then chains. This brings ability to use .result() method.

Note, that with this feature, Broodies will not pass the 2.2.4 rule of the Promises/A+ spec.

Promise.all(promises: Array[Promise]) -> Promise
Promise.resolve(value: any) -> Promise

Returns new resolved Promise.

Promise.reject(error: any) -> Promise

Returns new rejected Promise.