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

Function decodeString

packages/effect/src/encoding/SchemaBinary.ts:3810–3830  ·  view source on GitHub ↗
(dict: DictRead, layout: LeafLayout, r: Reader)

Source from the content-addressed store, hash-verified

3808}
3809
3810function decodeString(dict: DictRead, layout: LeafLayout, r: Reader): string {
3811 const slot = dictSlot(dict, layout.slot)
3812 const state = slot.state
3813 if (state === DICT_GAVE_UP) return r.readUtf8(r.end - r.pos)
3814 if (state === DICT_WATCHING) {
3815 const value = r.readUtf8(r.end - r.pos)
3816 dictWatch(slot, value)
3817 return value
3818 }
3819 const marker = r.uvarint()
3820 if ((marker & 1) === 1) {
3821 const ref = (marker - 1) / 2
3822 const values = slot.values
3823 if (ref >= values.length) invalid("a dictionary reference", marker, r.options)
3824 return values[ref]
3825 }
3826 if (marker !== 0) invalid("a dictionary marker", marker, r.options)
3827 const value = r.readUtf8(r.end - r.pos)
3828 dictAdd(slot, value)
3829 return value
3830}
3831
3832function encodeInterned(table: InternWrite, ctx: EncodeContext, layout: Layout, value: unknown, w: Writer) {
3833 if (!table.disabled) {

Callers 1

decodeValueUncheckedFunction · 0.70

Calls 6

dictSlotFunction · 0.85
dictWatchFunction · 0.85
dictAddFunction · 0.85
readUtf8Method · 0.80
invalidFunction · 0.70
uvarintMethod · 0.45

Tested by

no test coverage detected