MC/website/tests/build-artifact-scan.mjs
2026-11-27 23:43:05 +00:00

8 lines
469 B
JavaScript

export const ASSET_ENTRY=/"\/(?:[^"\\]|\\.)+":\["[^"\\]+","/g;
export function scanAssetChunk(combined,overlap=512){
const boundary=Math.max(0,combined.length-overlap);
// Match the full buffer, then assign a marker to the chunk containing its
// start. Cutting the buffer first loses markers that straddle the boundary.
const entries=[...combined.matchAll(ASSET_ENTRY)].filter(m=>m.index<boundary).map(m=>m[0]);
return {entries,carry:combined.slice(boundary)};
}