forked from unimatrix/web
8 lines
469 B
JavaScript
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)};
|
|
}
|

Staff