( ctx: EncodeContext, pairs: Array<ExtraPair>, obj: Record<string, unknown>, w: Writer, keys?: InternWrite | undefined )
| 3387 | } |
| 3388 | |
| 3389 | function encodeExtraPairs( |
| 3390 | ctx: EncodeContext, |
| 3391 | pairs: Array<ExtraPair>, |
| 3392 | obj: Record<string, unknown>, |
| 3393 | w: Writer, |
| 3394 | keys?: InternWrite | undefined |
| 3395 | ) { |
| 3396 | for (const [key, signature, keyBytes] of pairs) { |
| 3397 | const keyLength = keyBytes === undefined ? key.length : keyBytes.length |
| 3398 | const value = obj[key] |
| 3399 | const wire = valueWireCode(signature.layout, value, ctx.options) |
| 3400 | const kind = wire % FIELD_WIRE_FACTOR |
| 3401 | if (keys === undefined) { |
| 3402 | w.uvarint(keyLength * FIELD_WIRE_FACTOR + kind) |
| 3403 | } else { |
| 3404 | if (!keys.disabled) { |
| 3405 | const ref = internRef(keys, key) |
| 3406 | if (ref !== undefined) { |
| 3407 | w.uvarint(ref * 16 + kind * 2 + 1) |
| 3408 | issuePath[issuePathLen++] = key |
| 3409 | encodeWirePayload(ctx, signature.layout, value, wire, w) |
| 3410 | issuePathLen-- |
| 3411 | continue |
| 3412 | } |
| 3413 | internAdd(keys, key) |
| 3414 | } |
| 3415 | w.uvarint(keyLength * 16 + kind * 2) |
| 3416 | } |
| 3417 | if (keyBytes === undefined) w.string(key) |
| 3418 | else w.bytes(keyBytes) |
| 3419 | issuePath[issuePathLen++] = key |
| 3420 | encodeWirePayload(ctx, signature.layout, value, wire, w) |
| 3421 | issuePathLen-- |
| 3422 | } |
| 3423 | } |
| 3424 | |
| 3425 | // Decimal scale rides above the low three kind bits internally, avoiding a |
| 3426 | // second decimalScale scan when the payload is written. |
no test coverage detected