async function decode(buffer, charset) {
	let isJson = false;

	if (charset === "json") {
		charset = null;
		isJson = true;
	}

	if (!charset) {
		charset = settings.value.defaultFileEncoding;
	}

	charset = getEncoding(charset).name;
	const text = await execDecode(buffer, charset);

	if (isJson) {
		return JSON.parse(text);
	}

	return text;
}
Decodes arrayBuffer to String according given encoding type
@param {ArrayBuffer} buffer
@param {string} [charset]
@returns {Promise<string>}