From d9f0902979466ee75ab666f384f433c41757f793 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Sat, 2 Mar 2024 05:37:07 -0600 Subject: [PATCH] Move route deduplication function --- src/cloudflare.ts | 6 ++++++ src/deploy.ts | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cloudflare.ts b/src/cloudflare.ts index c420a58..3ef2daf 100644 --- a/src/cloudflare.ts +++ b/src/cloudflare.ts @@ -18,6 +18,12 @@ export type Route = { const delay = (n: number) => new Promise((res) => setTimeout(res, n)); +const unique = (xs: any[], property = 'id'): any[] => { + return Object.values( + xs.reduce((acc, obj) => ({ ...acc, [obj[property]]: obj })) + ); +}; + async function retry( fn: () => Promise, times = CLOUDFLARE_RETRIES, diff --git a/src/deploy.ts b/src/deploy.ts index 278ccdf..ab277ed 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -33,12 +33,6 @@ const attrDifference = (x: any[], y: any[], property: string) => { return x.filter((j) => !y.some((k) => j[property] == k[property])); }; -const unique = (xs: any[], property = 'id'): any[] => { - return Object.values( - xs.reduce((acc, obj) => ({ ...acc, [obj[property]]: obj })) - ); -}; - async function wrangler(config: (any) => any, fn: () => void) { const configSaved = fs.readFileSync(`${CWD}/wrangler.toml`).toString(); const configObject = parseTOML(configSaved);