Commit 69c6d7c9 authored by Romain Courteaud's avatar Romain Courteaud

Publish build version of rsvp.

parent 08ff89d4
......@@ -8,14 +8,14 @@ function promiseAtLeast(expected_count, promises) {
throw new TypeError('You must pass an array to all.');
}
function canceller() {
function canceller(msg) {
var promise;
for (var i = 0; i < promises.length; i++) {
promise = promises[i];
if (promise && typeof promise.then === 'function' &&
typeof promise.cancel === 'function') {
promise.cancel();
promise.cancel(msg);
}
}
}
......
......@@ -13,7 +13,7 @@ function size(object) {
function hash(promises) {
function canceller() {
function canceller(msg) {
var promise,
key;
for (key in promises) {
......@@ -22,7 +22,7 @@ function hash(promises) {
if (promise && typeof promise.then === 'function' &&
typeof promise.cancel === 'function') {
promise.cancel();
promise.cancel(msg);
}
}
}
......
......@@ -46,21 +46,21 @@ var Promise = function(resolver, canceller) {
this.on('error', onerror);
this.cancel = function () {
this.cancel = function (msg) {
// For now, simply reject the promise and does not propagate the cancel
// to parent or children
if (resolved) { return; }
promise.isCancelled = true;
if (canceller !== undefined) {
try {
canceller();
canceller(msg);
} catch (e) {
rejectPromise(e);
return;
}
}
// Trigger cancel?
rejectPromise(new CancellationError());
rejectPromise(new CancellationError(msg));
};
try {
......
......@@ -25,9 +25,9 @@ var Queue = function(thenable) {
return new Queue(thenable);
}
function canceller() {
function canceller(msg) {
for (var i = promise_list.length; i > 0; i--) {
promise_list[i - 1].cancel();
promise_list[i - 1].cancel(msg);
}
}
......@@ -70,10 +70,10 @@ var Queue = function(thenable) {
checkPromise(resolve(thenable));
queue.cancel = function () {
queue.cancel = function (msg) {
if (resolved) {return;}
resolved = true;
promise.cancel();
promise.cancel(msg);
promise.fail(function (rejectedReason) {
queue.isRejected = true;
queue.rejectedReason = rejectedReason;
......
......@@ -10,9 +10,9 @@ function resolve(thenable) {
}
}
return resolve(thenable);
}, function () {
}, function (msg) {
if ((thenable !== undefined) && (thenable.cancel !== undefined)) {
thenable.cancel();
thenable.cancel(msg);
}
});
}
......
......@@ -11,14 +11,14 @@ define("rsvp/all",
throw new TypeError('You must pass an array to all.');
}
function canceller() {
function canceller(msg) {
var promise;
for (var i = 0; i < promises.length; i++) {
promise = promises[i];
if (promise && typeof promise.then === 'function' &&
typeof promise.cancel === 'function') {
promise.cancel();
promise.cancel(msg);
}
}
}
......@@ -359,7 +359,7 @@ define("rsvp/hash",
function hash(promises) {
function canceller() {
function canceller(msg) {
var promise,
key;
for (key in promises) {
......@@ -368,7 +368,7 @@ define("rsvp/hash",
if (promise && typeof promise.then === 'function' &&
typeof promise.cancel === 'function') {
promise.cancel();
promise.cancel(msg);
}
}
}
......@@ -515,21 +515,21 @@ define("rsvp/promise",
this.on('error', onerror);
this.cancel = function () {
this.cancel = function (msg) {
// For now, simply reject the promise and does not propagate the cancel
// to parent or children
if (resolved) { return; }
promise.isCancelled = true;
if (canceller !== undefined) {
try {
canceller();
canceller(msg);
} catch (e) {
rejectPromise(e);
return;
}
}
// Trigger cancel?
rejectPromise(new CancellationError());
rejectPromise(new CancellationError(msg));
};
try {
......@@ -736,9 +736,9 @@ define("rsvp/queue",
return new Queue(thenable);
}
function canceller() {
function canceller(msg) {
for (var i = promise_list.length; i > 0; i--) {
promise_list[i - 1].cancel();
promise_list[i - 1].cancel(msg);
}
}
......@@ -781,10 +781,10 @@ define("rsvp/queue",
checkPromise(resolve(thenable));
queue.cancel = function () {
queue.cancel = function (msg) {
if (resolved) {return;}
resolved = true;
promise.cancel();
promise.cancel(msg);
promise.fail(function (rejectedReason) {
queue.isRejected = true;
queue.rejectedReason = rejectedReason;
......@@ -847,9 +847,9 @@ define("rsvp/resolve",
}
}
return resolve(thenable);
}, function () {
}, function (msg) {
if ((thenable !== undefined) && (thenable.cancel !== undefined)) {
thenable.cancel();
thenable.cancel(msg);
}
});
}
......
......@@ -48,14 +48,14 @@ define("rsvp/all",
throw new TypeError('You must pass an array to all.');
}
function canceller() {
function canceller(msg) {
var promise;
for (var i = 0; i < promises.length; i++) {
promise = promises[i];
if (promise && typeof promise.then === 'function' &&
typeof promise.cancel === 'function') {
promise.cancel();
promise.cancel(msg);
}
}
}
......@@ -396,7 +396,7 @@ define("rsvp/hash",
function hash(promises) {
function canceller() {
function canceller(msg) {
var promise,
key;
for (key in promises) {
......@@ -405,7 +405,7 @@ define("rsvp/hash",
if (promise && typeof promise.then === 'function' &&
typeof promise.cancel === 'function') {
promise.cancel();
promise.cancel(msg);
}
}
}
......@@ -552,21 +552,21 @@ define("rsvp/promise",
this.on('error', onerror);
this.cancel = function () {
this.cancel = function (msg) {
// For now, simply reject the promise and does not propagate the cancel
// to parent or children
if (resolved) { return; }
promise.isCancelled = true;
if (canceller !== undefined) {
try {
canceller();
canceller(msg);
} catch (e) {
rejectPromise(e);
return;
}
}
// Trigger cancel?
rejectPromise(new CancellationError());
rejectPromise(new CancellationError(msg));
};
try {
......@@ -773,9 +773,9 @@ define("rsvp/queue",
return new Queue(thenable);
}
function canceller() {
function canceller(msg) {
for (var i = promise_list.length; i > 0; i--) {
promise_list[i - 1].cancel();
promise_list[i - 1].cancel(msg);
}
}
......@@ -818,10 +818,10 @@ define("rsvp/queue",
checkPromise(resolve(thenable));
queue.cancel = function () {
queue.cancel = function (msg) {
if (resolved) {return;}
resolved = true;
promise.cancel();
promise.cancel(msg);
promise.fail(function (rejectedReason) {
queue.isRejected = true;
queue.rejectedReason = rejectedReason;
......@@ -884,9 +884,9 @@ define("rsvp/resolve",
}
}
return resolve(thenable);
}, function () {
}, function (msg) {
if ((thenable !== undefined) && (thenable.cancel !== undefined)) {
thenable.cancel();
thenable.cancel(msg);
}
});
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment