-
Notifications
You must be signed in to change notification settings - Fork 92
Fast byteLength() #333
Copy link
Copy link
Open
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interesttopic: api
Metadata
Metadata
Assignees
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interesttopic: api
What problem are you trying to solve?
new TextEncoder().encode(input).byteLengthis an order of magnitude slower than alternatives, including Node'sBuffer.byteLength(input)and even handwritten JavaScript implementations.Benchmarks
My benchmark repo includes a JS implementation that I believe is at least close enough to correct for benchmarking purposes, although I'm no expert in UTF-16 so there may be some mistakes.
What solutions exist today?
new Blob([input]).sizenew TextEncoder(input).byteLengthBuffer.byteLength(input)(Node only)How would you solve it?
Anything else?
No response