@metreeca/core - v0.9.19
    Preparing search index...

    Function createNamespace

    • Creates an immutable Namespace object for generating and accessing IRIs from a common base.

      Type Parameters

      • const T extends readonly string[]

        Predefined term names, inferred from the terms argument

      Parameters

      • namespace: string

        The absolute base IRI to which terms are appended

      • Optionalterms: T

        Optional array of predefined term names to restrict access to

      Returns Namespace<T>

      An immutable Namespace object with typed term properties

      If the namespace is not a valid absolute IRI, or if any term produces an invalid IRI during initialisation. For open namespaces, also throws when accessing a term that produces an invalid IRI. For closed namespaces, also throws when accessing an unknown term name.

      Open namespaces (no terms provided): Accept any term name dynamically, constructing IRIs on demand.

      Closed namespaces (terms provided): Restrict access to predefined terms only, throwing errors for unknown term names.

      Warning

      Accessing an unknown term on a closed namespace throws a RangeError at runtime, even though TypeScript's type system may not flag the access at compile time (e.g., when using bracket notation with a dynamic key).