JSSM, a JavaScript state machine - the FSM for FSL
    Preparing search index...

    Class Interner

    A string↔integer bimap. Assigns dense ids (0, 1, 2, …) in first-seen order; lookups are O(1) both directions. Grows monotonically — there is no removal, matching machine semantics (states and actions are fixed after construction; late interning only happens for never-matching lookups such as hook registrations naming unknown states).

    const i = new Interner();
    i.intern('red'); // 0
    i.intern('green'); // 1
    i.intern('red'); // 0 (idempotent)
    i.id_of('green'); // 1
    i.name_of(0); // 'red'

    pair_key

    Index
    • Return the id for name without interning, or undefined when the name has never been interned. This is the hot-path probe for user-supplied names.

      Parameters

      • name: string

        The string to look up.

      Returns number

      interner.id_of('mauve');  // undefined — never interned
      
    • Return the id for name, assigning the next dense id if the name has not been seen before.

      Parameters

      • name: string

        The string to intern.

      Returns number

      The (possibly newly assigned) integer id.

      interner.intern('red');  // 0 on first call, 0 on every later call
      
    • Return the name for id, or undefined for an id never assigned.

      Parameters

      • id: number

        The integer id to invert.

      Returns string

      interner.name_of(0);  // 'red'