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

Function decodeOneShot

packages/effect/src/encoding/SchemaBinary.ts:5324–5349  ·  view source on GitHub ↗
(
  layout: Layout,
  bytes: Uint8Array,
  options: SchemaAST.ParseOptions,
  mode: Mode
)

Source from the content-addressed store, hash-verified

5322let pooledReader: Reader | undefined = new Reader()
5323
5324function decodeOneShot(
5325 layout: Layout,
5326 bytes: Uint8Array,
5327 options: SchemaAST.ParseOptions,
5328 mode: Mode
5329): unknown {
5330 const r = pooledReader ?? new Reader()
5331 const pooled = r === pooledReader
5332 if (pooled) pooledReader = undefined
5333 r.reset(bytes, 0, bytes.length, options, undefined, mode, undefined)
5334 const savedPathLen = issuePathLen
5335 issuePathLen = 0
5336 try {
5337 const n = r.uvarint()
5338 if (n === 0) invalid("nonzero frame length", undefined, options)
5339 const saved = r.enter(n)
5340 const value = decodeFrameBody(layout, r, mode)
5341 r.exit(saved)
5342 if (r.pos !== bytes.length) invalid("no leftover bytes", undefined, options)
5343 return value
5344 } finally {
5345 issuePathLen = savedPathLen
5346 r.release()
5347 if (pooled) pooledReader = r
5348 }
5349}
5350
5351function makeTransformation(
5352 layout: Layout,

Callers 1

makeTransformationFunction · 0.85

Calls 7

decodeFrameBodyFunction · 0.85
enterMethod · 0.80
exitMethod · 0.80
invalidFunction · 0.70
resetMethod · 0.65
releaseMethod · 0.65
uvarintMethod · 0.45

Tested by

no test coverage detected