Commit cdad6cd7 authored by Tristan Cavelier's avatar Tristan Cavelier

Promise.timeout correct context are now assigned to called functions

parent 6a331465
...@@ -325,14 +325,14 @@ Promise.timeout = function (item, timeout) { ...@@ -325,14 +325,14 @@ Promise.timeout = function (item, timeout) {
var next = new Promise(), solver, i; var next = new Promise(), solver, i;
solver = next.defer(); solver = next.defer();
i = setTimeout(function () { i = setTimeout(function () {
solver.reject.apply(next, [new Error("Timeout")]); solver.reject(new Error("Timeout"));
}, timeout); }, timeout);
Promise.when(item, function () { Promise.when(item, function () {
clearTimeout(i); clearTimeout(i);
solver.resolve.apply(next, arguments); solver.resolve.apply(solver, arguments);
}, function () { }, function () {
clearTimeout(i); clearTimeout(i);
solver.reject.apply(next, arguments); solver.reject.apply(solver, arguments);
}); });
return next; return next;
}; };
......
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