Delta-Pack - v0.2.9
    Preparing search index...

    Function EnumType

    • Create an enumeration type with a fixed set of string values.

      Enums are encoded using the minimum number of bits needed to represent all options. For example, 4 options use 2 bits, 8 options use 3 bits.

      Type Parameters

      • const N extends string
      • const O extends readonly string[]

      Parameters

      • name: N

        The type name (must start with uppercase, e.g., "Direction")

      • options: O

        Array of string values for the enum

      Returns { type: "enum"; options: O; name: N; numBits: number }

      const Direction = EnumType("Direction", ["up", "down", "left", "right"]);
      const Status = EnumType("Status", ["pending", "active", "completed", "failed"]);

      const Player = ObjectType("Player", {
      facing: ReferenceType(Direction),
      status: ReferenceType(Status),
      });