( carry: Buffer | null, chunkBuf: Buffer, )
| 3128 | // null = carry spans whole chunk. Skips concat when carry provably isn't |
| 3129 | // a metadata line (markers sit at byte 1 after `{`). |
| 3130 | function resolveMetadataBuf( |
| 3131 | carry: Buffer | null, |
| 3132 | chunkBuf: Buffer, |
| 3133 | ): Buffer | null { |
| 3134 | if (carry === null || carry.length === 0) return chunkBuf |
| 3135 | if (carry.length < METADATA_PREFIX_BOUND) { |
| 3136 | return Buffer.concat([carry, chunkBuf]) |
| 3137 | } |
| 3138 | if (carry[0] === 0x7b /* { */) { |
| 3139 | for (const m of METADATA_MARKER_BUFS) { |
| 3140 | if (carry.compare(m, 0, m.length, 1, 1 + m.length) === 0) { |
| 3141 | return Buffer.concat([carry, chunkBuf]) |
| 3142 | } |
| 3143 | } |
| 3144 | } |
| 3145 | const firstNl = chunkBuf.indexOf(0x0a) |
| 3146 | return firstNl === -1 ? null : chunkBuf.subarray(firstNl + 1) |
| 3147 | } |
| 3148 | |
| 3149 | /** |
| 3150 | * Lightweight forward scan of [0, endOffset) collecting only metadata-entry lines. |
no outgoing calls
no test coverage detected