MCPcopy Create free account
hub / github.com/ambianic/peerfetch / textDecode

Method textDecode

javascript/src/peerfetch.ts:576–592  ·  view source on GitHub ↗
(arrayBuffer: any)

Source from the content-addressed store, hash-verified

574 }
575
576 textDecode (arrayBuffer: any) {
577 let decodedString: string = ""
578 if ('TextDecoder' in window) {
579 // Decode as UTF-8
580 var dataView = new DataView(arrayBuffer)
581 var decoder = new TextDecoder('utf8')
582 decodedString = decoder.decode(dataView)
583 } else {
584 // Fallback decode as ASCII
585 let jsonKey: string = "";
586 (new Uint8Array(arrayBuffer)).forEach(function (byte: number) {
587 decodedString += String.fromCharCode(byte);
588 })
589 }
590 console.debug({ decodedString })
591 return decodedString
592 }
593
594 jsonify (data: any) {
595 let decodedString

Callers 1

jsonifyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected