Repository navigation
Temporal, Uint8ClampedArray, Float16Array, SharedArrayBuffer, DataView, DisposableStack, FinalizationRegistry - #108
Merged
Merged
Conversation
Uint8ClampedArray clamps a number written to it into 0..255 and rounds half to even, where Uint8Array wraps. Float16Array keeps IEEE 754 binary16 bits, converted in TypeScript: LLVM lowers an f16 conversion to __truncsfhf2 and __extendhfsf2, which the MSVC runtime does not have. Both are one class, ConvertingTypedArray<S>, with TypedArray's methods over a number element. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DataView reads and writes every width JavaScript has (Int8 to Float64, Float16, BigInt64) at any byte offset of an ArrayBuffer or SharedArrayBuffer, big-endian unless littleEndian. A view made without a length follows a resizable buffer. A growable SharedArrayBuffer takes maxByteLength bytes up front, so grow() never moves them under another thread. Math.f16round. ArrayBuffer was in lib.ts but not in lib.d.ts, so no program could name it. Declaring it brings it to JavaScript's rules: resizable only with a maxByteLength, resize checks it, byteLength, and transfer(newByteLength) honours the length. A program calls a lib.ts class's methods by vtable slot, taken from lib.d.ts order, so each class lists its declared members first and its private ones after. Under -mm=own a DataView keeps its buffer (@keeps), as Response keeps its headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DisposableStack disposes its resources last added first, by `using` or dispose(), with use, adopt, defer, move and disposed. A resource that throws does not stop the rest; two failures make a SuppressedError holding both. A disposed stack takes nothing more (ReferenceError). [Symbol.dispose]() is the method named dispose here, so the class has dispose() alone. Under -mm=own, defer() and adopt() of a copied value compile; use() of an object, which keeps it and gives it back, does not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… rc" FinalizationRegistry<H, T> calls its callback with the held value of each target that has gone: freed by the collector (gc), given up by its owner (own), or never (none). There is no event loop, and the collector cannot run TypeScript mid-allocation, so callbacks run at the registry's next use: register(), unregister() or cleanupSome() (the TC39 proposal's). Targets and unregister tokens are held weakly. No runtime change: it is built on WeakRef, so it has WeakRef's models, gc, own and none. tests.ps1 and tests.sh skip a test whose first line starts with "// not rc" under -mm=rc, as they skip "// not own" under -mm=own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ISO 8601 calendar's part of Temporal, with from (ISO 8601 text), compare, add, subtract, until, since, equals, toString and toJSON, and _with for with. Spans are kept as seconds plus nanoseconds, exact past the 104 days a number of nanoseconds holds. Not here: ZonedDateTime, PlainYearMonth, PlainMonthDay, time zones other than UTC and the present system offset, other calendars, and options bags. Instant.epochNanoseconds is a 64-bit bigint (years 1677-2262). README lists the classes added on this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t again A class inside `declare namespace` without its own `declare` had its ..new and ..instanceOf defined in every program as well as in the library: a debug link failed with duplicate symbols on every test (release dropped them). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the missing globals, using MDN's Global Objects as the reference.
JSONalready existed. One commit per group:ConvertingTypedArray<S>, with TypedArray's methods over anumberelement. Clamped writes go into 0..255 and round half to even. Float16 converts binary16 in TypeScript, because LLVM'sf16conversions call__truncsfhf2and__extendhfsf2, which the MSVC runtime lacks.Math.f16round: DataView covers every width, both endiannesses, and views that follow a resizable or growable buffer's length. A growable SharedArrayBuffer allocatesmaxByteLengthup front, sogrow()never moves its bytes.ArrayBufferis now declared inlib.d.ts; before this no program could name it. With that it follows JS: resizable only when givenmaxByteLength,byteLength, andtransfer(newByteLength)honours the length. Under-mm=owna DataView keeps its buffer (@keeps).use,adopt,defer,move,dispose, andusing. Two failures become aSuppressedError. Under own,deferandadoptof a copied value work;useof an object does not.WeakRef, so it needs no runtime change and works under gc, own and none (not rc). There is no event loop, so callbacks run at the registry's nextregister,unregisterorcleanupSome. The test runners gain a// not rctag.Duration,Instant,PlainDate,PlainTime,PlainDateTime,Now. Not included: ZonedDateTime, time zones, other calendars, options bags.withis spelled_with, as on Array.Things worth knowing
lib.tsclass's methods by vtable slot, taken from the member order inlib.d.ts. Private methods count too, so each class lists its declared members first.check_declarations.ps1does not catch a wrong order: DataView returned garbage until I fixed it.0gives+0; the library usesx * -1insteadbigintby anintconstant is done in 32 bitsTesting
🤖 Generated with Claude Code