Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Yet another Promises/A+ implementation optimized for speed and simplicity.
JavaScript Makefile
Failed to load latest commit information.
src Bad idea, wrong implementation
test resolver
.gitignore Initial commit
.npmignore ignore
LICENSE 0.3.4
Makefile resolver
README.md update README
bower.json bump
davy.js Bad idea, wrong implementation
davy.min.js Bad idea, wrong implementation
davy.min.js.map Bad idea, wrong implementation
index.js add tests
package.json bump

README.md

Promises/A+ logo

Davy Jones

Yet another Promises/A+ implementation optimized for speed and simplicity.

API

new Davy(resolver)

Create a new promise. The passed in function will receive functions resolve, reject, notify as its arguments which can be called to seal the fate of the created promise.

.then(onFulfill, onReject, onNotify)

Returns a new promise chained from this promise. The new promise will be rejected or resolved defer on the passed onFulfill, onReject, onNotify and the state of this promise.

.catch(handler)

This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise. Any exception happening in a .then-chain will propagate to nearest .catch handler.

.progress(handler)

This is a progress handler, shortcut for calling .then(null, null, handler) on this promise.

.throw(handler)

Like .catch, but any unhandled rejection that ends up here will be thrown as an error.

.finally(handler)

Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise.

.spread(onFulfill, onReject)

Like calling .then, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.

Davy.resolve(value)

Returns a Promise object that is resolved with the given value. If the value is a thenable (i.e. has a then method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value.

Davy.reject(reason)

Returns a Promise object that is rejected with the given reason.

Davy.defer()

Create a promise with undecided fate and return a Resolver to control it.

Davy.all(iterable)

Returns a promise that resolves when all of the promises in iterable have resolved. The result is passed an array of values from all the promises. If something passed in the iterable array is not a promise, it's converted to one by Promise.cast. If any of the passed in promises rejects, the all Promise immediately rejects with the value of the promise that rejected, discarding all the other promises whether or not they have resolved.

Davy.race(iterable)

Returns a promise that either resolves when the first promise in the iterable resolves, or rejects when the first promise in the iterable rejects.

Davy.wrap(nodeFunction)

Returns a function that will wrap the given nodeFunction. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.

Something went wrong with that request. Please try again.