@alpaca-software/40kdc-data
    Preparing search index...

    Class Collection<T, V>

    A collection of one entity type, exposing id/name/faction lookups.

    Iterable: for (const unit of units) { … }.

    Type Parameters

    • T

      the raw (generated) record type

    • V

      the linked view type returned to callers

    Implements

    • Iterable<V>
    Index

    Constructors

    Accessors

    Methods

    • Look up by exact id.

      Parameters

      • id: string

      Returns V | undefined

    • Look up by exact id within a faction. Use this when an id is shared across factions (e.g. chaos-land-raider lives under five Chaos factions) and a faction context is known — get would return whichever copy was registered first, which may belong to the wrong faction. Returns undefined when no record with that id belongs to factionId.

      Parameters

      • id: string
      • factionId: string

      Returns V | undefined

    • Whether a record with this exact id exists.

      Parameters

      • id: string

      Returns boolean

    • Find one record by id or name. Name matching is diacritic- and punctuation-insensitive (see normalizeName), trying, in order: exact id → exact normalized name → normalized-name substring. Returns the first match; names can repeat across factions, so use findAll or byFaction when a query may be ambiguous.

      Parameters

      • query: string

      Returns V | undefined

      units.find("Kharn"); // resolves "Khârn the Betrayer"
      
    • All records matching a query, by the same rules as find. An exact id match returns just that record; otherwise every normalized-name-exact match is returned, falling back to every normalized-name-substring match. Useful to surface (rather than silently collapse) names shared across factions.

      Parameters

      • query: string

      Returns V[]

    • All records belonging to a faction id (empty if the type has no faction).

      Parameters

      • factionId: string

      Returns V[]