diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-23 23:07:54 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 17:37:54 +0530 |
commit | d6d437c4dce9beb6b304c481812e65d6751cbeb7 (patch) | |
tree | 5284d5b294a39204005b3aad8a752d10fc3dec67 /ext/cron/01_cron.ts | |
parent | 6238b0a4579539a627d192e0ce2c4a10993aeb8c (diff) |
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.
Diffstat (limited to 'ext/cron/01_cron.ts')
-rw-r--r-- | ext/cron/01_cron.ts | 17 |
1 files changed, 8 insertions, 9 deletions
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> | void) | ({ backoffSchedule?: number[]; signal?: AbortSignal }), - handlerOrOptions2?: - | (() => Promise<void> | void) - | ({ backoffSchedule?: number[]; signal?: AbortSignal }), + handler2?: () => Promise<void> | 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> | 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"); |