Comparing version 0.2.0 to 0.2.1
@@ -141,2 +141,3 @@ | ||
pending = undefined; | ||
return value; | ||
}; | ||
@@ -148,3 +149,3 @@ | ||
"reject": function (reason) { | ||
resolve(reject(reason)); | ||
return resolve(reject(reason)); | ||
} | ||
@@ -178,3 +179,2 @@ }; | ||
promise.emit = function (op, resolved /* ...args */) { | ||
resolved = resolved || identity; | ||
var args = Array.prototype.slice.call(arguments, 2); | ||
@@ -186,2 +186,3 @@ var result; | ||
result = fallback.apply(descriptor, arguments); | ||
resolved = resolved || identity; | ||
return resolved(result); | ||
@@ -248,4 +249,4 @@ }; | ||
}, function fallback(op, resolved) { | ||
var rejection = reject(reason); | ||
return resolved ? resolved(rejection) : rejection; | ||
resolved = resolved || identity; | ||
return resolved(reject(reason)); | ||
}, function valueOf() { | ||
@@ -288,2 +289,5 @@ var rejection = create(reject.prototype); | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
var method = object[name]; | ||
if (!method) throw new Error("No such method " + name + " on object " + object); | ||
if (!method.apply) throw new Error("Property " + name + " on object " + object + " is not a method"); | ||
return object[name].apply(object, args); | ||
@@ -305,16 +309,13 @@ } | ||
*/ | ||
exports.def = function (object) { | ||
exports.def = def; | ||
function def(object) { | ||
return Promise({ | ||
"isDef": function () {} | ||
}, function fallback(op, resolve) { | ||
}, function fallback(op, resolved) { | ||
var args = Array.prototype.slice.call(arguments, 2); | ||
var result = send.apply(undefined, [object, op].concat(args)); | ||
// TODO? return resolve ? resolve(result) : result; | ||
return result; | ||
resolved = resolved || identity; | ||
return resolved(result); | ||
}, function valueOf() { | ||
return { | ||
'toString': function () { | ||
return '[object Promise def]' | ||
} | ||
}; | ||
return object.valueOf(); | ||
}); | ||
@@ -373,3 +374,3 @@ } | ||
* | ||
* /!\ WARNING: this method is expiermental and likely | ||
* /!\ WARNING: this method is experimental and likely | ||
* to be removed on the grounds that it probably | ||
@@ -376,0 +377,0 @@ * will result in composition hazards. |
{ | ||
"name": "q", | ||
"description": "defer/when-style promises (CommonJS/Promises/B)", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"homepage": "http://github.com/kriskowal/q/", | ||
@@ -22,2 +22,6 @@ "author": "Kris Kowal <kris@cixar.com> (http://github.com/kriskowal/)", | ||
"main": "lib/q.js", | ||
"modules": { | ||
"util": "./lib/q/util.js", | ||
"queue": "./lib/q/queue.js" | ||
}, | ||
"repository": { | ||
@@ -24,0 +28,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
67775
23
1212
505
2
80