-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
On non-Node.js without XHR+Blob, this uses Buffer polyfill when available. And Buffer polyfill is slow and buggy.
Specific issue:
delete globalThis.TextDecoder
delete globalThis.TextEncoder
require('fast-text-encoding')
console.log(new TextDecoder().decode(Uint8Array.of(0xf0, 0x90, 0x80)).length)
console.log(new TextEncoder().encode('\ud800\ud800'))Node.js:
1
<Buffer ef bf bd ef bf bd>
Hermes:
3
<Buffer ef bf bd>
Also, why does it return Buffer instances?
And without Buffer global this is even worse:
delete globalThis.TextDecoder
delete globalThis.TextEncoder
delete globalThis.Buffer
require('fast-text-encoding')
console.log(new TextDecoder().decode(Uint8Array.of(0xf0, 0x90, 0x80)).length)
console.log(new TextEncoder().encode('\ud800\ud800'))2
Uint8Array(0) []
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels