add rule definition with minimal dsl

This commit is contained in:
JOLIMAITRE Matthieu 2024-08-07 11:59:58 +02:00
parent fa524a5976
commit 084c5a2574
5 changed files with 48 additions and 15 deletions

View file

@ -12,3 +12,11 @@ export function next<T>(iterator: Iterator<T>) {
if (result === undefined) return null;
else return result as T;
}
export function split_once(text: string, separator: string) {
const cursor = text.indexOf(separator);
if (cursor === -1) return [text, null] as const;
const left = text.slice(0, cursor);
const right = text.slice(cursor + separator.length);
return [left, right] as const;
}