Skip to content

byteArray: Add compatibility toString property

This overrides, on each Uint8Array returned from an introspected function or from ByteArray.fromString() or ByteArray.fromGBytes(), the toString() property with a compatibility shim that preserves the old behaviour of ByteArray.prototype.toString() while logging a compatibility warning asking people to fix their code.

This ByteArray.toString() -> Uint8Array.toString() change has had more fallout in application code than I expected, so it seems better to preserve backwards compatibility. (The old behaviour was to decode the byte array into a string with default encoding UTF-8, and the default behaviour of Uint8Array is to return a string with the decimal digits of each byte joined with commas. So the effect was that strings like "97,98,99,100" would show up in UIs where previously "abcd" would have been printed.

This is only on specific instances, so Uint8Array.prototype.toString() remains untouched.

Merge request reports