MCPcopy
hub / github.com/colinhacks/zod / utf8ToBytes

Function utf8ToBytes

packages/zod/src/v4/classic/tests/codec-examples.test.ts:248–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246// ============================================================================
247
248const utf8ToBytes = () =>
249 z.codec(z.string(), z.instanceof(Uint8Array), {
250 decode: (str) => new TextEncoder().encode(str),
251 encode: (bytes) => new TextDecoder().decode(bytes),
252 });
253
254test("utf8ToBytes codec", () => {
255 const codec = utf8ToBytes();

Callers 1

Calls 3

stringMethod · 0.80
encodeMethod · 0.80
decodeMethod · 0.80

Tested by

no test coverage detected