@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
21 lines • 732 B
JavaScript
import { CompactWriteError } from "./compact-content-store.js";
/** Incremental descriptor packing; values and keys must already be references. */
export function* packPages(rows) {
let page = [];
let bytes = 2;
for (const row of rows) {
const size = Buffer.byteLength(JSON.stringify(row));
if (size + 2 > 65_536)
throw new CompactWriteError("size_limit");
if (page.length === 128 || bytes + size + Number(page.length > 0) > 65_536) {
yield page;
page = [];
bytes = 2;
}
bytes += size + Number(page.length > 0);
page.push(row);
}
if (page.length)
yield page;
}
//# sourceMappingURL=compact-index-pages.js.map