diff options
| author | Kenta Moriuchi <moriken@kimamass.com> | 2024-01-08 07:20:02 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-07 23:20:02 +0100 |
| commit | c2c115ebd8e29122ea0a1aaf041871189917e196 (patch) | |
| tree | 0dfa8f71a6a9568bf52b56a4a3b55b667daecf44 /ext/cron | |
| parent | a731647a5198905d439021737eaa8207ca9f7498 (diff) | |
fix(ext): enable prefer-primordials for internal TypeScript (#21813)
Enabled prefer-primordials lint for ext/cron and ext/kv.
Diffstat (limited to 'ext/cron')
| -rw-r--r-- | ext/cron/01_cron.ts | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ext/cron/01_cron.ts b/ext/cron/01_cron.ts index 1aa39cd45..263b5762a 100644 --- a/ext/cron/01_cron.ts +++ b/ext/cron/01_cron.ts @@ -1,7 +1,16 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core, internals } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { + ArrayPrototypeJoin, + NumberPrototypeToString, + TypeError, +} = primordials; +const { + isPromise, +} = core; +const { + op_cron_create, op_cron_next, } = core.ensureFastOps(); @@ -15,7 +24,7 @@ export function formatToCronSchedule( if (value === undefined) { return "*"; } else if (typeof value === "number") { - return value.toString(); + return NumberPrototypeToString(value); } else { const { exact } = value as { exact: number | number[] }; if (exact === undefined) { @@ -39,9 +48,9 @@ export function formatToCronSchedule( } } else { if (typeof exact === "number") { - return exact.toString(); + return NumberPrototypeToString(exact); } else { - return exact.join(","); + return ArrayPrototypeJoin(exact, ","); } } } @@ -104,7 +113,7 @@ function cron( throw new TypeError("Deno.cron requires a handler"); } - const rid = core.ops.op_cron_create( + const rid = op_cron_create( name, schedule, options?.backoffSchedule, @@ -130,7 +139,7 @@ function cron( } try { const result = handler(); - const _res = result instanceof Promise ? (await result) : result; + const _res = isPromise(result) ? (await result) : result; success = true; } catch (error) { console.error(`Exception in cron handler ${name}`, error); |
