Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ES6-compatible and Promises/A+ implementation for Node.js and browsers
JavaScript Other

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
benchmarks
lib
test
.gitignore
.travis.yml
Makefile
README.md
index.js
package.json
test-runner.js
vow.min.js

README.md

Vow Build Status

Promises/A+ specification compatible promises library. See https://github.com/promises-aplus/promises-spec.

Getting Started

In the Node.js

You can install using Node Package Manager (npm):

npm install vow

In the Browsers

<script type="text/javascript" src="vow.min.js"></script>

Also RequireJS module format supported.

API

Vow.promise()

Create promise

var promise = Vow.promise();    

Promise API

fulfill(value)

Fulfill promise with given value

promise.fulfill(value);

reject(reason)

Reject promise with given reason

promise.reject(error);

isFulfilled()

Returns whether the promise is fulfilled

promise.isFulfilled();

isRejected()

Returns whether the promise is rejected

promise.isRejected();

isResolved()

Returns whether the promise is fulfilled or rejected

promise.isResolved();

then([onFulfilled], [onRejected])

Arranges for:

  • onFulfilled to be called with the value after promise is fulfilled,
  • onRejected to be called with the rejection reason after promise is rejected.

Returns a new promise. See Promises/A+ specification for details.

promise.then(onFulfilled, onRejected);

fail(onRejected)

Arranges to call onRejected on the promise's rejection reason if it is rejected.

spread([onFulfilled], [onRejected])

Like "then", but "spreads" the array into a variadic value handler.

Vow API

isPromise(value)

Returns whether the given value is a promise.

fulfill(value)

Returns a promise that has already been fulfilled with the given value. If value is a promise, returned promise will be fulfilled with fulfill/rejection value of given promise.

reject(reasonOrPromise)

Returns a promise that has already been rejected with the given value. If value is a promise, returned promise will be rejected with fulfill/rejection value of given promise.

resolve(value)

Returns a promise that has already been fulfilled with the given value. If value is a promise, returns promise.

when(valueOrPromise, [onFulfilled], [onRejected])

all(promisesOrValues)

allResolved(promisesOrValues)

any(promisesOrValues)

timeout(promise, timeout)

Something went wrong with that request. Please try again.