Comparing version 1.4.1 to 1.5.0
@@ -0,2 +1,8 @@ | ||
## 1.5.0 | ||
- Q.any gives an error message from the last rejected promise | ||
- Throw if callback supplied to "finally" is invalid (@grahamrhay) | ||
- Long stack trace improvements, can now construct long stack traces | ||
across rethrows. | ||
## 1.4.1 | ||
@@ -3,0 +9,0 @@ |
{ | ||
"name": "q", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "A library for promises (CommonJS/Promises/A,B,D)", | ||
@@ -30,6 +30,3 @@ "homepage": "https://github.com/kriskowal/q", | ||
}, | ||
"license": { | ||
"type": "MIT", | ||
"url": "http://github.com/kriskowal/q/raw/master/LICENSE" | ||
}, | ||
"license": "MIT", | ||
"main": "q.js", | ||
@@ -62,3 +59,3 @@ "files": [ | ||
"scripts": { | ||
"test": "jasmine-node spec && promises-aplus-tests spec/aplus-adapter", | ||
"test": "npm ls -s && jasmine-node spec && promises-aplus-tests spec/aplus-adapter && npm run -s lint", | ||
"test-browser": "opener spec/q-spec.html", | ||
@@ -65,0 +62,0 @@ "benchmark": "matcha", |
53
q.js
// vim:ts=4:sts=4:sw=4: | ||
/*! | ||
* | ||
* Copyright 2009-2012 Kris Kowal under the terms of the MIT | ||
* license found at http://github.com/kriskowal/q/raw/master/LICENSE | ||
* Copyright 2009-2017 Kris Kowal under the terms of the MIT | ||
* license found at https://github.com/kriskowal/q/blob/v1/LICENSE | ||
* | ||
@@ -193,3 +193,3 @@ * With parts by Tyler Close | ||
// "[object Object]", while in a real Node environment | ||
// `process.nextTick()` yields "[object process]". | ||
// `process.toString()` yields "[object process]". | ||
isNodeJS = true; | ||
@@ -331,2 +331,7 @@ | ||
var object_defineProperty = Object.defineProperty || function (obj, prop, descriptor) { | ||
obj[prop] = descriptor.value; | ||
return obj; | ||
}; | ||
var object_hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty); | ||
@@ -382,8 +387,8 @@ | ||
error !== null && | ||
error.stack && | ||
error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1 | ||
error.stack | ||
) { | ||
var stacks = []; | ||
for (var p = promise; !!p; p = p.source) { | ||
if (p.stack) { | ||
if (p.stack && (!error.__minimumStackCounter__ || error.__minimumStackCounter__ > p.stackCounter)) { | ||
object_defineProperty(error, "__minimumStackCounter__", {value: p.stackCounter, configurable: true}); | ||
stacks.unshift(p.stack); | ||
@@ -395,3 +400,4 @@ } | ||
var concatedStacks = stacks.join("\n" + STACK_JUMP_SEPARATOR + "\n"); | ||
error.stack = filterStackString(concatedStacks); | ||
var stack = filterStackString(concatedStacks); | ||
object_defineProperty(error, "stack", {value: stack, configurable: true}); | ||
} | ||
@@ -523,2 +529,10 @@ } | ||
/** | ||
* The counter is used to determine the stopping point for building | ||
* long stack traces. In makeStackTraceLong we walk backwards through | ||
* the linked list of promises, only stacks which were created before | ||
* the rejection are concatenated. | ||
*/ | ||
var longStackCounter = 1; | ||
// enable long stacks if Q_DEBUG is set | ||
@@ -596,2 +610,3 @@ if (typeof process === "object" && process && process.env && process.env.Q_DEBUG) { | ||
promise.stack = e.stack.substring(e.stack.indexOf("\n") + 1); | ||
promise.stackCounter = longStackCounter++; | ||
} | ||
@@ -606,4 +621,9 @@ } | ||
resolvedPromise = newPromise; | ||
promise.source = newPromise; | ||
if (Q.longStackSupport && hasStacks) { | ||
// Only hold a reference to the new promise if long stacks | ||
// are enabled to reduce memory usage | ||
promise.source = newPromise; | ||
} | ||
array_reduce(messages, function (undefined, message) { | ||
@@ -735,3 +755,3 @@ Q.nextTick(function () { | ||
} else { | ||
throw new Error("Can't join: not the same: " + x + " " + y); | ||
throw new Error("Q can't join: not the same: " + x + " " + y); | ||
} | ||
@@ -1633,9 +1653,8 @@ }); | ||
} | ||
function onRejected() { | ||
function onRejected(err) { | ||
pendingCount--; | ||
if (pendingCount === 0) { | ||
deferred.reject(new Error( | ||
"Can't get fulfillment value from any promise, all " + | ||
"promises were rejected." | ||
)); | ||
err.message = ("Q can't get fulfillment value from any promise, all " + | ||
"promises were rejected. Last error message: " + err.message); | ||
deferred.reject(err); | ||
} | ||
@@ -1764,2 +1783,5 @@ } | ||
Promise.prototype["finally"] = function (callback) { | ||
if (!callback || typeof callback.apply !== "function") { | ||
throw new Error("Q can't apply finally callback"); | ||
} | ||
callback = Q(callback); | ||
@@ -1928,2 +1950,5 @@ return this.then(function (value) { | ||
Q.denodeify = function (callback /*...args*/) { | ||
if (callback === undefined) { | ||
throw new Error("Q can't wrap an undefined function"); | ||
} | ||
var baseArgs = array_slice(arguments, 1); | ||
@@ -1930,0 +1955,0 @@ return function () { |
@@ -1,15 +0,8 @@ | ||
[![Build Status](https://secure.travis-ci.org/kriskowal/q.png?branch=master)](http://travis-ci.org/kriskowal/q) | ||
[![Build Status](https://secure.travis-ci.org/kriskowal/q.svg?branch=master)](http://travis-ci.org/kriskowal/q) | ||
[![CDNJS](https://img.shields.io/cdnjs/v/q.js.svg)](https://cdnjs.com/libraries/q.js) | ||
<a href="http://promises-aplus.github.com/promises-spec"> | ||
<img src="http://kriskowal.github.io/q/q.png" | ||
align="right" alt="Q logo" /> | ||
<img src="http://kriskowal.github.io/q/q.png" align="right" alt="Q logo" /> | ||
</a> | ||
*This is Q version 1, from the `v1` branch in Git. This documentation applies to | ||
the latest of both the version 1 and version 0.9 release trains. These releases | ||
are stable. There will be no further releases of 0.9 after 0.9.7 which is nearly | ||
equivalent to version 1.0.0. All further releases of `q@~1.0` will be backward | ||
compatible. The version 2 release train introduces significant and | ||
backward-incompatible changes and is experimental at this time.* | ||
If a function cannot return a value or throw an exception without | ||
@@ -83,3 +76,3 @@ blocking, it can return a promise instead. A promise is an object | ||
- A [component](https://github.com/component/component) as ``microjs/q`` | ||
- Using [bower](http://bower.io/) as `q#1.0.1` | ||
- Using [bower](http://bower.io/) as `q#^1.4.1` | ||
- Using [NuGet](http://nuget.org/) as [Q](https://nuget.org/packages/q) | ||
@@ -390,3 +383,3 @@ | ||
One sometimes-unintuive aspect of promises is that if you throw an | ||
One sometimes-unintuitive aspect of promises is that if you throw an | ||
exception in the fulfillment handler, it will not be caught by the error | ||
@@ -881,4 +874,4 @@ handler. | ||
Copyright 2009–2015 Kristopher Michael Kowal and contributors | ||
Copyright 2009–2017 Kristopher Michael Kowal and contributors | ||
MIT License (enclosed) | ||
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
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
123021
1877
875