1.1.0 • Published 8 years ago

q-ext v1.1.0

Weekly downloads
1
License
Apache 2.0
Repository
github
Last release
8 years ago

#q-ext NPM version Build Status Coverage Status Dependency Status devDependency Status

###What Methods to extend the Q promise library.

###Installation Via npm, simply run: npm install q-ext

###Usage

####allSettled(namedPromiseObject) -> Promise Simply pass an object with named promises. The results are grouped by result (fulfilled/rejected) which can then be spread() into a node-like callback which gives you the errorsByName and resultsByName. NOTE: Unlike traditional node callbacks, the errorsByName object is NEVER undefined (instead being an empty object):

qExt.allSettled({
    aSuccessfulPromise: q.resolve('result'),
    anotherSuccessfulPromise: q.resolve('anotherResult'),
    anUnsuccessfulPromise: q.reject('error'),
    anotherUnsuccessfulPromise: q.reject('anotherError')
}).spread(function (errorsByName, successesByName) {
    console.log('errors:', errorsByName);
    console.log('successes:', successesByName);
}).done();

Passing an array of promises defers to the traditional form:

qExt.allSettled([q.resolve('result'), q.reject('error')]).spread(function (success, error) {
    console.log('success:', success);
    console.log('error:', error);
}).done();
1.1.0

8 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago