mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:11:36 +00:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
22
src/test-utils/chunk-test-helpers.ts
Normal file
22
src/test-utils/chunk-test-helpers.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export function countLines(text: string): number {
|
||||
return text.split("\n").length;
|
||||
}
|
||||
|
||||
export function hasBalancedFences(chunk: string): boolean {
|
||||
let open: { markerChar: string; markerLen: number } | null = null;
|
||||
for (const line of chunk.split("\n")) {
|
||||
const match = line.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
const marker = match[2];
|
||||
if (!open) {
|
||||
open = { markerChar: marker[0], markerLen: marker.length };
|
||||
continue;
|
||||
}
|
||||
if (open.markerChar === marker[0] && marker.length >= open.markerLen) {
|
||||
open = null;
|
||||
}
|
||||
}
|
||||
return open === null;
|
||||
}
|
||||
Reference in New Issue
Block a user