MCPcopy Create free account
hub / github.com/Effect-TS/effect / encodeExtraPairs

Function encodeExtraPairs

packages/effect/src/encoding/SchemaBinary.ts:3389–3423  ·  view source on GitHub ↗
(
  ctx: EncodeContext,
  pairs: Array<ExtraPair>,
  obj: Record<string, unknown>,
  w: Writer,
  keys?: InternWrite | undefined
)

Source from the content-addressed store, hash-verified

3387}
3388
3389function 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.

Callers 3

encodeStructFieldsFunction · 0.85
encodeStructPositionalFunction · 0.85
encodeRunRowFunction · 0.85

Calls 7

valueWireCodeFunction · 0.85
internRefFunction · 0.85
encodeWirePayloadFunction · 0.85
internAddFunction · 0.85
uvarintMethod · 0.45
stringMethod · 0.45
bytesMethod · 0.45

Tested by

no test coverage detected