MCPcopy Create free account
hub / github.com/wevm/viem / bytesToString

Function bytesToString

src/utils/encoding/fromBytes.ts:217–227  ·  view source on GitHub ↗
(
  bytes_: ByteArray,
  opts: BytesToStringOpts = {},
)

Source from the content-addressed store, hash-verified

215 * // 'Hello world'
216 */
217export function bytesToString(
218 bytes_: ByteArray,
219 opts: BytesToStringOpts = {},
220): string {
221 let bytes = bytes_
222 if (typeof opts.size !== 'undefined') {
223 assertSize(bytes, { size: opts.size })
224 bytes = trim(bytes, { dir: 'right' })
225 }
226 return new TextDecoder().decode(bytes)
227}

Callers 4

fromBytesFunction · 0.85
fromBytes.bench.tsFile · 0.85
fromBytes.test.tsFile · 0.85
decodeStringFunction · 0.85

Calls 2

assertSizeFunction · 0.85
trimFunction · 0.85

Tested by

no test coverage detected