aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/util_promise_spec.lua4
-rw-r--r--util/promise.lua6
2 files changed, 4 insertions, 6 deletions
diff --git a/spec/util_promise_spec.lua b/spec/util_promise_spec.lua
index f64702bf..307c094a 100644
--- a/spec/util_promise_spec.lua
+++ b/spec/util_promise_spec.lua
@@ -498,10 +498,10 @@ describe("util.promise", function ()
local res1, res2;
local p1, p2 = promise.new(function (resolve) r1 = resolve end), promise.new(function (resolve) r2 = resolve end);
- local p = promise.join(p1, p2, function (_res1, _res2)
+ local p = promise.join(function (_res1, _res2)
res1, res2 = _res1, _res2;
return promise.resolve("works");
- end);
+ end, p1, p2);
local result;
local cb = spy.new(function (v)
diff --git a/util/promise.lua b/util/promise.lua
index 89bd1f26..ea30898c 100644
--- a/util/promise.lua
+++ b/util/promise.lua
@@ -146,12 +146,10 @@ local function all_settled(promises)
end);
end
-local function join(...)
+local function join(handler, ...)
local promises, n = { ... }, select("#", ...);
- local handler = promises[n];
- promises[n] = nil;
return all(promises):next(function (results)
- return handler(unpack(results, 1, n - 1));
+ return handler(unpack(results, 1, n));
end);
end