add rule definition with minimal dsl
This commit is contained in:
parent
fa524a5976
commit
084c5a2574
5 changed files with 48 additions and 15 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue