Lady [Mon, 22 May 2023 02:50:19 +0000 (19:50 -0700)]
Make base32 handling less forgiving
Ordinarily, one only encounters base32 strings of length 0, 2, 4, 5, or
7 characters (mod 8). If it is of length 3 or 6, the final character is
in the middle of an incomplete byte. As with length 1, this should
probably throw an error, as the other alternative is to entirely ignore
the character.
(It already did throw an error before this change, but
unintentionally.)
Lady [Sat, 20 May 2023 01:05:02 +0000 (18:05 -0700)]
Add base16 support to binary.js
Just iterating over the bytes and doing `$.toString(16).toUpperCase()`
or `parseInt($, 16)` might actually be faster, but I kind of like using
an actual algorithm to ensure parity with base64 ⁊·c processing.
Lady [Fri, 19 May 2023 07:20:39 +0000 (00:20 -0700)]
Fix base64 implementation
I believe that the old implementation was just wrong, and it simply
wasn’t caught because Deno’s `assertEquals` doesn’t actually know what
to do with raw buffers. Wrapping them to build typed arrays creates
working tests, and this implementation matches observed behaviour with
`atob` and `btoa`.
Lady [Tue, 20 Sep 2022 03:39:11 +0000 (20:39 -0700)]
Add to⸺Notation functions to numeric.js
The default Number::toString method provides a result which is
difficult to parse. Number::toExponential and Number::toFixed are
better; they are now provided via toExponentialNotation and
toFixedDecimalNotation. Support for big·ints has been added as well.
Lady [Thu, 8 Sep 2022 05:20:46 +0000 (22:20 -0700)]
Provide fake external constructor for Matcher
Classes which depend on identity for behaviours should not be exposed
because this inheritance can be modified at runtime. This commit
provides a fake Matcher constructor which simply calls the real one.
This has a side‐effect of reducing the amount of prototype modification
which this class setup entailed, at the cost of needing to manually
redefine all the properties from the internal Matcher constructor
prototype onto the external one.
Lady [Sun, 4 Sep 2022 21:47:15 +0000 (14:47 -0700)]
Treat object function args more consistently
Functions like getOwnPropertyKeys now do not require that their
arguments are objects, but *do* require that they are not null or
undefined. Similarly, toObject now throws for null and undefined
values, rather than returning an empty object. Use `toObject($ ?? {})`
if you need the old behaviour.