q-promise
promise polyfill with add-ons
Last updated 10 years ago by jgermade .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install q-promise 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.0                                ...           latest (10 years ago)

17 Versions

  • 1.0.0                                ...           10 years ago
  • 0.3.7                                ...           10 years ago
  • 0.3.6                                ...           10 years ago
  • 0.3.5                                ...           10 years ago
  • 0.3.4                                ...           10 years ago
  • 0.3.3                                ...           10 years ago
  • 0.3.2                                ...           10 years ago
  • 0.3.1                                ...           10 years ago
  • 0.3.0                                ...           10 years ago
  • 0.2.6                                ...           11 years ago
  • 0.2.5                                ...           11 years ago
  • 0.2.4                                ...           11 years ago
  • 0.2.3                                ...           11 years ago
  • 0.2.2                                ...           11 years ago
  • 0.2.1                                ...           11 years ago
  • 0.1.2                                ...           11 years ago
  • 0.1.1                                ...           11 years ago
Maintainers (1)
Downloads
Total 19
Today 0
This Week 0
This Month 19
Last Day 0
Last Week 19
Last Month 0
Dependencies (0)
None
Dev Dependencies (10)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE