Comparing version 0.1.0 to 0.1.1
14
index.js
@@ -1,2 +0,4 @@ | ||
var Q = require('q') | ||
if (!('Promise' in this)) { | ||
var Promise = require('bluebird') | ||
} | ||
var K = function (x) { return x } | ||
@@ -12,7 +14,7 @@ | ||
advice.before = (advice.before || K(Q())).bind(state) | ||
advice.after = (advice.after || K(Q())).bind(state) | ||
advice.before = (advice.before || K(Promise.resolve())).bind(state) | ||
advice.after = (advice.after || K(Promise.resolve())).bind(state) | ||
// TODO: optimize cases | ||
return Q(advice.before()) | ||
return Promise.cast(advice.before()) | ||
.then(function (val) { | ||
@@ -22,6 +24,6 @@ // shortcircuit promiser | ||
? val | ||
: promiser() | ||
: Promise.cast(promiser()) | ||
.then(function (val) { | ||
state.val = val | ||
return Q(advice.after()) | ||
return Promise.cast(advice.after()) | ||
.then(function (valAfter) { | ||
@@ -28,0 +30,0 @@ // check for override promiser value |
{ | ||
"name": "bbq", | ||
"author": "jden <jason@denizac.org>", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "AOP with Promises", | ||
@@ -21,4 +21,4 @@ "keywords": [ | ||
"dependencies": { | ||
"q": "~0.9.6" | ||
"bluebird": "~0.11.5-0" | ||
} | ||
} |
var chai = require('chai') | ||
chai.should() | ||
var Q = require('q') | ||
var Promise = require('bluebird') | ||
@@ -16,3 +16,3 @@ describe('bbq', function () { | ||
bbq(function () { | ||
return Q.promise(function (resolve) { | ||
return new Promise(function (resolve) { | ||
beforeCalled.should.equal(true) | ||
@@ -51,3 +51,3 @@ afterCalled.should.equal(false) | ||
bbq(function () { | ||
return Q.promise(function (resolve, reject) { | ||
return new Promise(function (resolve, reject) { | ||
reject(new Error('promiser should not be called')) | ||
@@ -78,3 +78,3 @@ }) | ||
bbq(function () { | ||
return Q() | ||
return Promise.resolve() | ||
}, { | ||
@@ -81,0 +81,0 @@ before: function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5875
108
+ Addedbluebird@~0.11.5-0
+ Addedbluebird@0.11.6(transitive)
- Removedq@~0.9.6
- Removedq@0.9.7(transitive)