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

Function arraySlot

packages/effect/src/encoding/SchemaBinary.ts:3933–3939  ·  view source on GitHub ↗
(layout: ArrayLayout, index: number, count: number)

Source from the content-addressed store, hash-verified

3931}
3932
3933function arraySlot(layout: ArrayLayout, index: number, count: number): Layout {
3934 const elementLen = layout.elements.length
3935 if (index < elementLen) return layout.elements[index].layout
3936 const tailLen = Math.max(0, layout.rest.length - 1)
3937 const tailThreshold = Math.max(elementLen, count - tailLen)
3938 return index >= tailThreshold ? layout.rest[index - tailThreshold + 1] : layout.rest[0]
3939}
3940
3941function encodeArray(ctx: EncodeContext, layout: ArrayLayout, arr: ReadonlyArray<unknown>, w: Writer) {
3942 const count = arr.length

Callers 2

encodeArrayFunction · 0.85
decodeArrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected