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

Function decodeNumberRun

packages/effect/src/encoding/SchemaBinary.ts:5038–5064  ·  view source on GitHub ↗
(out: Array<unknown>, count: number, r: Reader)

Source from the content-addressed store, hash-verified

5036}
5037
5038function decodeNumberRun(out: Array<unknown>, count: number, r: Reader): Array<unknown> {
5039 const mode = r.byte()
5040 if (mode === NUMBER_RUN_F64) {
5041 if (r.remaining !== count * 8) invalid("f64", undefined, r.options)
5042 for (let i = 0; i < count; i++) out[i] = r.f64()
5043 return out
5044 }
5045 if (mode === NUMBER_RUN_DECIMAL) {
5046 for (let i = 0; i < count; i++) {
5047 issuePath[issuePathLen++] = i
5048 const code = r.uvarint()
5049 const scale = code % 16
5050 if (scale > DECIMAL_SCALE_MAX) invalid("decimal", undefined, r.options)
5051 const value = decodeSignMagnitude((code - scale) / 16)
5052 out[i] = scale === 0 ? value : value / POW10[scale]
5053 issuePathLen--
5054 }
5055 return out
5056 }
5057 if (mode !== NUMBER_RUN_VARINT) invalid("f64", undefined, r.options)
5058 for (let i = 0; i < count; i++) {
5059 issuePath[issuePathLen++] = i
5060 out[i] = r.numberVarint()
5061 issuePathLen--
5062 }
5063 return out
5064}
5065
5066function decodeUnion(layout: UnionLayout, r: Reader): unknown {
5067 const kind = r.byte()

Callers 1

decodeArrayFunction · 0.85

Calls 6

decodeSignMagnitudeFunction · 0.85
invalidFunction · 0.70
byteMethod · 0.45
f64Method · 0.45
uvarintMethod · 0.45
numberVarintMethod · 0.45

Tested by

no test coverage detected