cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
636 stars 324 forks source link

TextDecoder option fatal unsupported #1598

Closed Mikssxed closed 1 week ago

Mikssxed commented 1 week ago

Hello, when function fromUtf8 from your library runs it all times show me error Failed to construct 'TextDecoder': the 'fatal' option is unsupported.. This is your code:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromUtf8 = exports.toUtf8 = void 0;
function toUtf8(str) {
    return new TextEncoder().encode(str);
}
exports.toUtf8 = toUtf8;
/**
 * Takes UTF-8 data and decodes it to a string.
 *
 * In lossy mode, the replacement character � is used to substitude invalid
 * encodings. By default lossy mode is off and invalid data will lead to exceptions.
 */
function fromUtf8(data, lossy = false) {
    const fatal = !lossy;
    return new TextDecoder("utf-8", { fatal }).decode(data);
}
exports.fromUtf8 = fromUtf8;
//# sourceMappingURL=utf8.js.map

How could I use it properly? I got node v20.11.0