From d6d437c4dce9beb6b304c481812e65d6751cbeb7 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Tue, 23 Jan 2024 23:07:54 +1100 Subject: BREAKING(unstable): remove `Deno.cron()` overload (#22035) This change removes the currently deprecated `Deno.cron()` overload with `options` as a potential last argument. This might be fine to do now, in a major release, as `Deno.cron()` is an unstable API. I thought of doing this while working on #22021. If this is not ready to remove, I can instead set the removal version of this overload for Deno v2. Note: this overload was deprecated in Deno v1.38.2 (#21225). So it's been deprecated for over 2 months. --- ext/cron/01_cron.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'ext') diff --git a/ext/cron/01_cron.ts b/ext/cron/01_cron.ts index b3d417e3c..84e5c7fff 100644 --- a/ext/cron/01_cron.ts +++ b/ext/cron/01_cron.ts @@ -84,9 +84,7 @@ function cron( handlerOrOptions1: | (() => Promise | void) | ({ backoffSchedule?: number[]; signal?: AbortSignal }), - handlerOrOptions2?: - | (() => Promise | void) - | ({ backoffSchedule?: number[]; signal?: AbortSignal }), + handler2?: () => Promise | void, ) { if (name === undefined) { throw new TypeError("Deno.cron requires a unique name"); @@ -98,16 +96,17 @@ function cron( schedule = parseScheduleToString(schedule); let handler: () => Promise | void; - let options: { backoffSchedule?: number[]; signal?: AbortSignal } | undefined; + let options: + | { backoffSchedule?: number[]; signal?: AbortSignal } + | undefined = undefined; if (typeof handlerOrOptions1 === "function") { handler = handlerOrOptions1; - if (typeof handlerOrOptions2 === "function") { - throw new TypeError("options must be an object"); + if (handler2 !== undefined) { + throw new TypeError("Deno.cron requires a single handler"); } - options = handlerOrOptions2; - } else if (typeof handlerOrOptions2 === "function") { - handler = handlerOrOptions2; + } else if (typeof handler2 === "function") { + handler = handler2; options = handlerOrOptions1; } else { throw new TypeError("Deno.cron requires a handler"); -- cgit v1.2.3