Diff

util/promise.lua @ 11486:78d843faaffc

util.promise: Switch order of parameters to join() This saves awkward fiddlery with varargs and also echoes the signature of pcall/xpcall.
author Matthew Wild <mwild1@gmail.com>
date Thu, 25 Mar 2021 15:08:22 +0000
parent 11485:7d42ed3a8a40
child 11947:073e53b72792
line wrap: on
line diff
--- a/util/promise.lua	Thu Mar 25 14:32:32 2021 +0000
+++ b/util/promise.lua	Thu Mar 25 15:08:22 2021 +0000
@@ -146,12 +146,10 @@
 	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