Протестировано с: Chrome в Linux 70.0.3538.110
Ошибка: Ранее неудачный textDecoder.decode
вызов вызовет сбой последовательных вызовов.
const log = console.log
let string = 'Hello ♥ world! ♥'
let textEncoder = new TextEncoder()
let bytes = textEncoder.encode(string)
let textDecoder = new TextDecoder('utf-8', {fatal: true})
try {
// Comment away this line and the code below will work
log(textDecoder.decode(new DataView(bytes.buffer, 0, 19)))
} catch (e) {
log('After this failed the next try will also fail')
}
log(textDecoder.decode(new DataView(bytes.buffer, 0, 20)))