Comparing version 0.8.11 to 0.8.12
{ | ||
"name": "q", | ||
"version": "0.8.11", | ||
"version": "0.8.12", | ||
"description": "A library for promises (CommonJS/Promises/A,B,D)", | ||
@@ -10,5 +10,9 @@ "homepage": "https://github.com/kriskowal/q", | ||
"promise", | ||
"promises", | ||
"promises-a", | ||
"promises-a-plus", | ||
"deferred", | ||
"future", | ||
"async", | ||
"flow control", | ||
"fluent", | ||
@@ -47,6 +51,7 @@ "browser", | ||
"jasmine-node": "*", | ||
"opener": "*" | ||
"opener": "*", | ||
"promises-aplus-tests": "~1.0" | ||
}, | ||
"scripts": { | ||
"test": "jasmine-node spec", | ||
"test": "jasmine-node spec && promises-aplus-tests spec/aplus-adapter", | ||
"test-browser": "opener spec/q-spec.html", | ||
@@ -53,0 +58,0 @@ "lint": "jshint q.js", |
28
q.js
@@ -580,2 +580,11 @@ // vim:ts=4:sts=4:sw=4: | ||
/** | ||
* @returns whether the given object can be coerced to a promise. | ||
* Otherwise it is a fulfilled value. | ||
*/ | ||
exports.isPromiseAlike = isPromiseAlike; | ||
function isPromiseAlike(object) { | ||
return object && typeof object.then === "function"; | ||
} | ||
/** | ||
* @returns whether the given object is a resolved promise. | ||
@@ -594,3 +603,3 @@ */ | ||
function isFulfilled(object) { | ||
return !isPromise(valueOf(object)); | ||
return !isPromiseAlike(valueOf(object)); | ||
} | ||
@@ -632,3 +641,2 @@ | ||
function reject(exception) { | ||
exception = exception || new Error(); | ||
var rejection = makePromise({ | ||
@@ -682,3 +690,3 @@ "when": function (rejected) { | ||
// assimilate thenables, CommonJS/Promises/A | ||
if (object && typeof object.then === "function") { | ||
if (isPromiseAlike(object)) { | ||
var deferred = defer(); | ||
@@ -826,3 +834,3 @@ object.then(deferred.resolve, deferred.reject, deferred.notify); | ||
try { | ||
return fulfilled ? fulfilled(value) : value; | ||
return typeof fulfilled === "function" ? fulfilled(value) : value; | ||
} catch (exception) { | ||
@@ -834,3 +842,3 @@ return reject(exception); | ||
function _rejected(exception) { | ||
if (rejected) { | ||
if (typeof rejected === "function") { | ||
makeStackTraceLong(exception, resolvedValue); | ||
@@ -847,3 +855,3 @@ try { | ||
function _progressed(value) { | ||
return progressed ? progressed(value) : value; | ||
return typeof progressed === "function" ? progressed(value) : value; | ||
} | ||
@@ -1390,4 +1398,3 @@ | ||
* | ||
* var readFile = require("fs").readFile; | ||
* Q.nfapply(readFile, [__filename]) | ||
* Q.nfapply(FS.readFile, [__filename]) | ||
* .then(function (content) { | ||
@@ -1411,4 +1418,3 @@ * }) | ||
* | ||
* var readFile = require("fs").readFile; | ||
* Q.nfcall(readFile, __filename) | ||
* Q.nfcall(FS.readFile, __filename) | ||
* .then(function (content) { | ||
@@ -1454,3 +1460,2 @@ * }) | ||
* | ||
* var FS = (require)("fs"); | ||
* Q.napply(FS.readFile, FS, [__filename]) | ||
@@ -1470,3 +1475,2 @@ * .then(function (content) { | ||
* | ||
* var FS = (require)("fs"); | ||
* Q.ncall(FS.readFile, FS, __filename) | ||
@@ -1473,0 +1477,0 @@ * .then(function (content) { |
[![Build Status](https://secure.travis-ci.org/kriskowal/q.png)](http://travis-ci.org/kriskowal/q) | ||
<a href="http://promises-aplus.github.com/promises-spec"> | ||
<img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png" | ||
align="right" alt="Promises/A+ logo" /> | ||
</a> | ||
If a function cannot return a value or throw an exception without | ||
@@ -7,5 +12,5 @@ blocking, it can return a promise instead. A promise is an object | ||
function may eventually provide. A promise can also be used as a | ||
proxy for a [remote object][Q-Comm] to overcome latency. | ||
proxy for a [remote object][Q-Connection] to overcome latency. | ||
[Q-Comm]: https://github.com/kriskowal/q-comm | ||
[Q-Connection]: https://github.com/kriskowal/q-connection | ||
@@ -12,0 +17,0 @@ On the first pass, promises can mitigate the “[Pyramid of |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
68839
1461
639
5
1