Skip to content

Count object separators when splitting data into chunks - #1401

Open
hiSandog wants to merge 1 commit into
CodebuffAI:mainfrom
hiSandog:fix/object-chunk-size-20260922-a824e7
Open

hiSandog wants to merge 1 commit into
CodebuffAI:mainfrom
hiSandog:fix/object-chunk-size-20260922-a824e7

Conversation

@hiSandog

Copy link
Copy Markdown
Contributor

splitData({ data: { a: 1, b: 2 }, maxChunkSize: 12 }) currently returns a single 13-character JSON object. Appending a property to a nonempty object removes two braces but adds a comma, so the combined length must subtract one character rather than three. The same undercount affects recursively split properties.

Correct both object-length calculations and add regression cases for ordinary properties, recursively split properties, and an object that exactly fits its limit.

Validation: all 19 tests in common/src/util/__tests__/split-data.test.ts pass with Bun 1.3.14, including two regression cases that fail before the fix. The two changed files also pass strict TypeScript checking, ESLint, and git diff --check.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant