MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / encodeAny

Function encodeAny

runtime/src/rt.js:129–138  ·  view source on GitHub ↗
(exps, value)

Source from the content-addressed store, hash-verified

127
128/* JS value -> handle; chooses tag from typeof. Bigint also accepted for int. */
129function encodeAny(exps, value) {
130 if (value === null || value === undefined) return exps.host_edge_encode(TAG_NONE, 0, 0);
131 if (typeof value === 'boolean') return encodeBool(exps, value);
132 if (typeof value === 'bigint') return encodeInt(exps, Number(value));
133 if (typeof value === 'number') {
134 return Number.isInteger(value) ? encodeInt(exps, value) : encodeFloat(exps, value);
135 }
136 if (typeof value === 'string') return encodeStr(exps, value);
137 throw new Error(`cannot encode JS value of type ${typeof value}`);
138}

Callers 1

makeRtFunction · 0.85

Calls 4

encodeBoolFunction · 0.85
encodeIntFunction · 0.85
encodeFloatFunction · 0.85
encodeStrFunction · 0.85

Tested by

no test coverage detected