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

Function decode

src/utils/encodings.js:175–191  ·  view source on GitHub ↗
(buffer, charset)

Source from the content-addressed store, hash-verified

173 * @returns {Promise<string>}
174 */
175export async function decode(buffer, charset) {
176 let isJson = false;
177
178 if (charset === "json") {
179 charset = null;
180 isJson = true;
181 }
182
183 charset = getEncodingName(charset);
184 const text = await execDecode(buffer, charset);
185
186 if (isJson) {
187 return JSON.parse(text);
188 }
189
190 return text;
191}
192
193/**
194 * Encodes text to ArrayBuffer according given encoding type

Callers 5

openFile.jsFile · 0.90
readFileFunction · 0.90
readFileFunction · 0.90
readFileFunction · 0.90
readFileFunction · 0.90

Calls 2

getEncodingNameFunction · 0.85
execDecodeFunction · 0.85

Tested by

no test coverage detected