Skip to content

Commit

Permalink
[skip ci] optimize regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
GooseOb committed May 10, 2024
1 parent 46b9f2c commit 2c9e4e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions build-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { BunBuildUserscriptConfig } from 'bun-build-userscript';

const define: Record<string, string> = {};

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];
Expand Down

0 comments on commit 2c9e4e5

Please sign in to comment.