Lady [Sun, 5 Nov 2023 20:41:30 +0000 (15:41 -0500)]
Redo create⸺Function A·P·I in function.js
`createCallableFunction` and `createIllegalConstructor` are now joined
by a `createArrowFunction`, and all three have extremely similar
interfaces. Further refactoring is probably necessary elsewhere in the
codebase to make use of these changes.
Lady [Sat, 21 Oct 2023 19:29:12 +0000 (15:29 -0400)]
Improve object.js a·p·i
- Add tests for functions which were formerly just re·exports of
standard library functions.
- Test constructibility, name, and length for all exported functions.
- Replace `isFrozenObject` and `isSealedObject` with `isUnfrozenObject`
and `isUnsealedObject`, as the former versions return _true_, not
_false_, when provided with a non·object argument.
- Revise `setPrototype` to have better behaviours than the Ecmascript
implementation when provided with a non·object argument.
Lady [Tue, 5 Sep 2023 00:27:48 +0000 (20:27 -0400)]
Cast to function name in createCallableFunction
This requires moving the definition of `toFunctionName` inside the same
closure as `createCallableFunction` to ensure that it is defined before
`createCallableFunction` is called (e·g when defining
`ordinaryHasInstance`).
Lady [Mon, 4 Sep 2023 21:15:24 +0000 (17:15 -0400)]
Rename make⸺ to create⸺ in function.js
“make⸺” names are used in the Ecmascript specification to describe
in‐place modifications. These functions return new values, so “create”
is more appropriate.
Lady [Sat, 22 Jul 2023 07:42:24 +0000 (00:42 -0700)]
Ensure each function in function.js has proper name
Also provides a wrapper for `constructor` for parity even though this
isn’t strictly required, and simplifies the implementation of
`isConstructor` to make use of `completesNormally`.
Lady [Sat, 22 Jul 2023 06:30:50 +0000 (23:30 -0700)]
Add iterator function builders; use in string.js
This commit adds a number of new `⸺IteratorFunction` functions in a
new `iterable.js` module, for building “iterator functions” from
various kinds of iterable object (as well as generator functions, which
are not themselves iterable). These functions are useful
metaprogramming tools for creating iterators akin to those produced by
the native Ecmascript builtins like `Array::values` or `Map::entries`
when starting from an already‐iterable base value but needing to map it
somehow.
The existing functions `codeUnits`, `codepoints`, and `scalarValues`
already fell into this category and have been refactored to make use of
the new technique.
Lady [Tue, 27 Jun 2023 01:07:19 +0000 (18:07 -0700)]
Add buffer getters and setters to binary.js
These are rough equivalents to the `DataView` methods, but can be
called with any kind of array buffer or array buffer view. Internally,
they (weakly) remember a `DataView` instance for each buffer and use
that for accessing values (to ensure correct endianness behaviour).
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.