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

Function internAdd

packages/effect/src/encoding/SchemaBinary.ts:3674–3689  ·  view source on GitHub ↗
(table: InternWrite, value: unknown)

Source from the content-addressed store, hash-verified

3672}
3673
3674function internAdd(table: InternWrite, value: unknown) {
3675 const values = table.values
3676 if (table.refs !== undefined) {
3677 if (table.hits === 0 && values.length >= INTERN_DISABLE_AT) {
3678 table.disabled = true
3679 table.refs = undefined
3680 return
3681 }
3682 table.refs.set(value, values.length)
3683 } else if (values.length >= INTERN_MAP_AT) {
3684 const refs = table.refs = new Map()
3685 for (let i = 0; i < values.length; i++) refs.set(values[i], i)
3686 refs.set(value, values.length)
3687 }
3688 values.push(value)
3689}
3690
3691// A connection dictionary: string tables that outlive a single frame. The
3692// writer and the reader build the same tables from the same frames, so a

Callers 2

encodeExtraPairsFunction · 0.85
encodeInternedFunction · 0.85

Calls 2

setMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected