@blockchaincommons/known-values - v1.0.0-beta.4
    Preparing search index...

    Class KnownValuesStore

    A bidirectional registry of known values: codepoint → value and assigned name → value.

    register replaces by codepoint: a later registration of the same codepoint replaces the earlier value and retires its name. A later registration of the same name on another codepoint moves the name index to it; the earlier codepoint keeps its own assignedName and both count in size (the reference behaves the same). The empty name of the unit value is indexed like any other, so byName("") answers codepoint 0. Iteration is in registration order; a replaced codepoint keeps its original position. Values are frozen, so clone() may share them.

    Every argument is checked before the store is touched: a value that is not a KnownValue, or a name that is not a string, is a KnownValuesError InvalidParameter.

    Implements

    Index
    • Add or replace a value. A later registration of the same codepoint replaces the earlier one and retires its name; the same name on another codepoint moves the name index (see the class doc).

      Parameters

      Returns void

      KnownValuesError InvalidParameter when knownValue is not a KnownValue

    • The registered value with this assigned name, if any.

      Parameters

      • assignedName: string

      Returns KnownValue | undefined

      KnownValuesError InvalidParameter when assignedName is not a string

    • The name this store assigns to the value's codepoint, if any.

      Parameters

      Returns string | undefined

      KnownValuesError InvalidParameter when knownValue is not a KnownValue

    • The store's name for the codepoint, else the value's own name.

      Parameters

      Returns string

      KnownValuesError InvalidParameter when knownValue is not a KnownValue

    • Register every entry of the .json registry files in path, in the host's directory order (the reference's load_from_directory): a missing path or a non-directory registers nothing; the first unreadable or unparsable file stops the load with nothing registered.

      Parameters

      • path: string

      Returns number

      How many values the directory held

      KnownValuesError Io or Json for the first failing file or directory

    • Register the values of every configured directory, tolerating per-file errors (the reference's load_from_config): later directories replace earlier ones by codepoint, and the result lists the directories processed and every error met.

      Parameters

      Returns LoadResult