q-promise

1.0.0 • Public • Published

q-promise

travis Build Status Wercker wercker status

Full Promises/A+ compliance

Installation

npm install q-promise --save
 
# alternatively you can use bower (minified version by default)
bower install q-promise --save

ES6 Promise

// q-promise respects the es6 promise specification
// you can use q-promise as global polyfill
 
if( !window.Promise ) {
  window.Promise = $q;
}

Example

$q(function (resolve, reject) {
        resolve('gogogo!');
    })
 
    .then(function (result) {
        console.log('checkpoint 1', result);
        throw 'whoops!';
    })
 
    .then(function (result) {
        console.log('checkpoint 2', result);
    },function (result) {
        console.log('checkpoint 2.1', result);
        return qPromise(function (resolve, reject) {
            setTimeout(function () { resolve('all right!'); }, 400);
        });
    })
 
    .then(function (result) {
        console.log('checkpoint 3', result);
    }, function (reason) {
        console.log('checkpoint 3.1', reason);
    })
;

output:

checkpoint 1 gogogo!
checkpoint 2.1 whoops!
# elapsed 400ms
checkpoint 3 all right!

Tests

make test

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.06latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.06
0.3.77
0.3.60
0.3.50
0.3.40
0.3.30
0.3.20
0.3.10
0.3.00
0.2.60
0.2.50
0.2.40
0.2.30
0.2.20
0.2.10
0.1.20
0.1.10

Package Sidebar

Install

npm i q-promise

Weekly Downloads

12

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jgermade