From 140c4707ceda4fda8c80cd6cdab3b68eefdad8a0 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Fri, 15 Sep 2023 19:56:07 -0700 Subject: [PATCH] fix: rename to syncArgs --- packages/exo/src/exo-tools.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/exo/src/exo-tools.js b/packages/exo/src/exo-tools.js index 574ec9075f..e0023ad4e5 100644 --- a/packages/exo/src/exo-tools.js +++ b/packages/exo/src/exo-tools.js @@ -33,30 +33,30 @@ const { defineProperties, fromEntries } = Object; const MinMethodGuard = M.call().rest(M.any()).returns(M.any()); /** - * @param {Passable[]} args + * @param {Passable[]} syncArgs * @param {MethodGuardPayload} methodGuardPayload * @param {string} [label] * @returns {Passable[]} Returns the args that should be passed to the * raw method */ -const defendSyncArgs = (args, methodGuardPayload, label = undefined) => { +const defendSyncArgs = (syncArgs, methodGuardPayload, label = undefined) => { const { argGuards, optionalArgGuards, restArgGuard } = methodGuardPayload; const paramsPattern = M.splitArray( argGuards, optionalArgGuards, restArgGuard, ); - mustMatch(harden(args), paramsPattern, label); + mustMatch(harden(syncArgs), paramsPattern, label); if (restArgGuard !== undefined) { - return args; + return syncArgs; } const declaredLen = argGuards.length + (optionalArgGuards ? optionalArgGuards.length : 0); - if (args.length <= declaredLen) { - return args; + if (syncArgs.length <= declaredLen) { + return syncArgs; } // Ignore extraneous arguments, as a JS function call would do. - return args.slice(0, declaredLen); + return syncArgs.slice(0, declaredLen); }; /** @@ -69,8 +69,8 @@ const defendSyncMethod = (method, methodGuardPayload, label) => { const { returnGuard } = methodGuardPayload; const { syncMethod } = { // Note purposeful use of `this` and concise method syntax - syncMethod(...args) { - const realArgs = defendSyncArgs(harden(args), methodGuardPayload, label); + syncMethod(...syncArgs) { + const realArgs = defendSyncArgs(harden(syncArgs), methodGuardPayload, label); const result = apply(method, this, realArgs); mustMatch(harden(result), returnGuard, `${label}: result`); return result; @@ -115,12 +115,12 @@ const defendAsyncMethod = (method, methodGuardPayload, label) => { asyncMethod(...args) { const awaitList = awaitIndexes.map(i => args[i]); const p = Promise.all(awaitList); - const rawArgs = [...args]; + const syncArgs = [...args]; const resultP = E.when(p, awaitedArgs => { for (let j = 0; j < awaitIndexes.length; j += 1) { - rawArgs[awaitIndexes[j]] = awaitedArgs[j]; + syncArgs[awaitIndexes[j]] = awaitedArgs[j]; } - const realArgs = defendSyncArgs(rawArgs, rawMethodGuardPayload, label); + const realArgs = defendSyncArgs(syncArgs, rawMethodGuardPayload, label); return apply(method, this, realArgs); }); return E.when(resultP, result => {