From 5f1610e861bb4dd02200adccd5a7058eed2212e0 Mon Sep 17 00:00:00 2001 From: yhx-12243 Date: Tue, 4 Jun 2024 14:25:41 -0400 Subject: [PATCH] feat(core): add bigint support (#1410) --- packages/core/src/command/index.ts | 8 ++++++++ packages/core/src/command/parser.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/packages/core/src/command/index.ts b/packages/core/src/command/index.ts index 9ba3868c3..3b2d0f0b6 100644 --- a/packages/core/src/command/index.ts +++ b/packages/core/src/command/index.ts @@ -190,6 +190,14 @@ export class Commander { throw new Error('internal.invalid-natural') }, { numeric: true }) + this.domain('bigint', (source, session) => { + try { + return BigInt(source) + } catch { + throw new Error("internal.invalid-integer") + } + }, { numeric: true }) + this.domain('date', (source, session) => { const timestamp = Time.parseDate(source) if (+timestamp) return timestamp diff --git a/packages/core/src/command/parser.ts b/packages/core/src/command/parser.ts index dc967529d..85103de4d 100644 --- a/packages/core/src/command/parser.ts +++ b/packages/core/src/command/parser.ts @@ -182,6 +182,7 @@ export namespace Argv { integer: number posint: number natural: number + bigint: bigint date: Date img: JSX.IntrinsicElements['img'] image: JSX.IntrinsicElements['img']