Skip to main content

Crate javascript_globals

Crate javascript_globals 

Source
Expand description

§JavaScript Globals

Global identifiers from different JavaScript environments

Rust fork of https://www.npmjs.com/package/globals

§Representation

Every unique global name has one shared u16 ID. A GlobalSet stores one membership bit per ID and a sorted list of the writable IDs, so environments do not repeat names or hash-table metadata. Identical environments share the same static set.

The generated data.bin contains the PHF tables, concatenated UTF-8 names, name offsets, membership bitsets, and writable-ID lists. The generated module converts those byte ranges into typed static arrays during const evaluation; no data is parsed or allocated at runtime.

A name lookup uses the shared PHF to find a candidate ID, verifies the candidate string, checks the environment’s membership bit, then binary-searches its writable IDs. Iteration scans set bits and uses a const-generated reference table into the shared name blob.

Environment lookup uses a generated string match. The separate environment array is referenced only by iteration, allowing linkers to discard it when callers use only Globals::get.

Structs§

GlobalEntries
Iterator over a GlobalSet’s entries.
GlobalSet
A compact map of global names to their writability.
Globals
A map of environment names to their global variable maps.

Statics§

GLOBALS
All available environments.
GLOBALS_BUILTIN
GLOBALS_ES2026