Skip to content

v3.2.1

Latest

Choose a tag to compare

@evanrichards evanrichards released this 12 Sep 02:45
3d0408f

This release contains every change since v3.1.0. The version 3.2.0 never
got a release, so the decimal.js work arrives here too.

Fix TextDecoder.decode for an ArrayBuffer and a DataView (#3)

TextDecoder.decode returned an empty string for an ArrayBuffer and for a
DataView. The polyfill read input.length, and neither type has that
property. The method did not throw, so a caller lost the data without a
signal.

The decoder now converts any BufferSource to a Uint8Array first, and it
keeps the byte offset and the byte length of a view. An input that is not a
BufferSource throws a TypeError.

The decoder also builds the intermediate string in chunks of 8192 bytes. A
benchmark in the sandbox decoded 600 KB in 131 ms before this change and in
20 ms after it.

Action for an embedder: guest code that works around the bug with
decode(new Uint8Array(buffer)) keeps working. The workaround is no longer
necessary.

Mount decimal.js in the sandbox and add a Decimal global (#2)

The package vendors the decimal.js source as a string constant. The virtual
file system mounts it always, so guest code runs
import Decimal from 'decimal.js' without the option nodeModules. The new
option enableDecimalGlobal registers the class Decimal as a global.

The package exports the source through the subpath ./decimal-source for an
embedder that drives quickjs-emscripten-core directly.