From 2c9e4e5a8a3b31a209540fd04257286d1f7b8d0c Mon Sep 17 00:00:00 2001 From: GooseOb Date: Fri, 10 May 2024 17:04:17 +0200 Subject: [PATCH] [skip ci] optimize regexes --- build-config.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build-config.ts b/build-config.ts index 508e5d0..d731461 100644 --- a/build-config.ts +++ b/build-config.ts @@ -3,9 +3,11 @@ import { BunBuildUserscriptConfig } from 'bun-build-userscript'; const define: Record = {}; -const raw = (await readFile('index.ts', 'utf8')).match(/declare const.+?;/s)[0]; +const raw = (await readFile('index.ts', 'utf8')).match( + /declare const[^;]+?;/ +)[0]; -const pattern = /(\S+): (\S+)[,;]/g; +const pattern = /(\S+):\s*([^,;]+)/g; let tmp; while ((tmp = pattern.exec(raw))) define[tmp[1]] = tmp[2];