You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
parser: dedupe the twin string/Buffer large-JSONL scanners #643
src/parser.ts contains two structurally identical hand-rolled JSON scanners: the string version (findJsonStringEnd and friends, src/parser.ts:152-478) and a Buffer twin of every function (findJsonStringEndBuffer and friends, src/parser.ts:483-822). Roughly 340 lines exist twice. Any scanner fix (escape handling, nesting off-by-one) must land in both; a fix applied to one branch produces divergent parsing between small-string and large-buffer inputs, which surfaces as a silent size-dependent miscount rather than an error.
Evidence
src/parser.ts:152 function findJsonStringEnd(source: string, ...)
src/parser.ts:483 function findJsonStringEndBuffer(source: Buffer, ...)
Extract one scanner module generic over an indexable source (both string and Buffer support charCodeAt-style access; a tiny accessor closure keeps the hot path monomorphic). Delete the twin. Existing parser tests plus a fixture run through both entry paths guard the refactor.
Working on this. Approach as proposed: extract a single scanner generic over an indexable source (accessor closure to keep the hot path monomorphic), route both the string and Buffer entry points through it, and add a fixture test that runs identical content through both paths. PR will follow after #644 lands, per the one-PR-at-a-time rule in CONTRIBUTING.
Activity
avs-io commentedon Jul 16, 2026
Working on this. Approach as proposed: extract a single scanner generic over an indexable source (accessor closure to keep the hot path monomorphic), route both the string and Buffer entry points through it, and add a fixture test that runs identical content through both paths. PR will follow after #644 lands, per the one-PR-at-a-time rule in CONTRIBUTING.
parser: dedupe the twin string/Buffer large-JSONL scanners (#698)