From 6e342b9667e8f3405fd8cc72b377a5794939dcbb Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 24 Mar 2023 20:23:38 -0500 Subject: [PATCH] Tweak types a little --- src/pipeline.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pipeline.ts b/src/pipeline.ts index 3c5d1dc..9d379a4 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -6,15 +6,12 @@ type PolicyTuple = [policy: Policy, opts?: Opts]; /** Helper type for proper type inference of PolicyTuples in the pipeline. */ // https://stackoverflow.com/a/75806165 // https://stackoverflow.com/a/54608401 -type PolicyTuplesRest = { +type PolicySpread = { [K in keyof T]: PolicyTuple | Policy; }; /** Processes messages through multiple policies, bailing early on rejection. */ -async function pipeline

( - msg: InputMessage, - policies: [...PolicyTuplesRest

], -): Promise { +async function pipeline(msg: InputMessage, policies: [...PolicySpread]): Promise { for (const item of policies) { const [policy, opts] = toTuple(item); const result = await policy(msg, opts);