MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / decodeText

Function decodeText

src/utils/helpers.js:64–74  ·  view source on GitHub ↗

* @deprecated This method is deprecated, use 'encodings.decode' instead. * Decodes arrayBuffer to String according given encoding type * @param {ArrayBuffer} arrayBuffer * @param {String} [encoding='utf-8']

(arrayBuffer, encoding = "utf-8")

Source from the content-addressed store, hash-verified

62 * @param {String} [encoding='utf-8']
63 */
64 decodeText(arrayBuffer, encoding = "utf-8") {
65 const isJson = encoding === "json";
66 if (isJson) encoding = "utf-8";
67
68 const uint8Array = new Uint8Array(arrayBuffer);
69 const result = new TextDecoder(encoding).decode(uint8Array);
70 if (isJson) {
71 return this.parseJSON(result);
72 }
73 return result;
74 },
75 /**
76 * Gets icon according to filename
77 * @param {string} filename

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected