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

Function encodeUtf8Scratch

packages/sql/pg/src/PgTypes.ts:149–154  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

147
148/** Encodes into `scratchUtf8`, returning how many bytes it holds, or -1. */
149const encodeUtf8Scratch = (text: string): number => {
150 const capacity = text.length * 3
151 if (capacity > scratchUtf8Limit) return -1
152 if (capacity > scratchUtf8.length) scratchUtf8 = new Uint8Array(capacity)
153 return textEncoder.encodeInto(text, scratchUtf8).written
154}
155
156const encodeUtf8 = (text: string): Uint8Array => {
157 const length = text.length

Callers 2

encodeUtf8Function · 0.85
encodeUtf8PrefixedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected