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

Function encodeParseUnsafe

packages/sql/pg/src/PgProtocol.ts:746–768  ·  view source on GitHub ↗
(options: Omit<Parse, "_tag">)

Source from the content-addressed store, hash-verified

744 * @since 4.0.0
745 */
746const encodeParseUnsafe = (options: Omit<Parse, "_tag">): Uint8Array => {
747 const writer = begin(0x50)
748 writer.cString(options.name)
749 writer.cString(options.query)
750 const parameterTypes = options.parameterTypes
751 const count = requireUint16Count(parameterTypes.length, "Parse parameter type")
752 writer.reserve(2 + count * 4)
753 const bytes = writer.bytes
754 let offset = writer.offset
755 bytes[offset] = count >>> 8
756 bytes[offset + 1] = count
757 offset += 2
758 for (let index = 0; index < count; index++) {
759 const oid = parameterTypes[index]
760 bytes[offset] = oid >>> 24
761 bytes[offset + 1] = oid >>> 16
762 bytes[offset + 2] = oid >>> 8
763 bytes[offset + 3] = oid
764 offset += 4
765 }
766 writer.offset = offset
767 return end()
768}
769
770/**
771 * Encodes a `Parse` message.

Callers 1

encodeParseFunction · 0.85

Calls 5

requireUint16CountFunction · 0.85
beginFunction · 0.70
endFunction · 0.70
cStringMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected