turbodombuilder - v0.9.66
    Preparing search index...

    Class TurboNestedMap<ValueType, KeyType>

    TurboNestedMap

    A map of arbitrary nesting depth, addressed via ...keys paths.

    Type Parameters

    • ValueType = any

      The type of stored values.

    • KeyType = string | symbol | number

      The type of keys at each level of the path. Defaults to string | symbol | number.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    nestedMap: TurboNestedMapNode<KeyType, any> = ...

    Accessors

    • get entries(): [KeyType, ValueType][]

      Returns [KeyType, ValueType][]

      All leaf [key, value] pairs in the nested map, sorted alphabetically by key.

    • get keys(): KeyType[]

      Returns KeyType[]

      All leaf keys in the nested map, sorted alphabetically.

    • get values(): ValueType[]

      Returns ValueType[]

      All leaf values in the nested map, sorted alphabetically by key.

    • get paths(): KeyType[][]

      Returns KeyType[][]

      All leaf key paths in the map.

    • get size(): number

      Returns number

      Number of all leaf entries in the nested map.

    Methods

    • Function

      get

      Parameters

      • ...keys: KeyType[]

        Ordered path from outermost to innermost key.

      Returns ValueType

      The stored value, or undefined if not found.

      Retrieve the value at the given key path.

    • Function

      getFlat

      Parameters

      • flatKey: string | number

        A flat key produced by flattenKey.

      Returns ValueType

      The stored value, or undefined if not found.

      Retrieve the value at the given flat key.

    • Function

      getKey

      Parameters

      Returns KeyType[]

      The key path, or undefined if not found.

      Find the key path of the first occurrence of the given value.

    • Function

      getKeys

      Parameters

      Returns KeyType[][]

      Array of key paths.

      Find the key paths of all occurrences of the given value.

    • Function

      getFlatKey

      Parameters

      Returns string | number

      The flat key, or undefined if not found.

      Return the flat key of the first occurrence of the given value.

    • Function

      set

      Parameters

      • value: ValueType

        The value to store.

      • ...keys: KeyType[]

        Ordered path from outermost to innermost key.

      Returns void

      Store a value at the given key path. Intermediate nodes are created automatically.

    • Function

      setFlat

      Parameters

      • value: ValueType

        The value to store.

      • flatKey: string | number

        A flat key produced by flattenKey.

      Returns void

      Store a value at the given flat key.

    • Function

      has

      Parameters

      • ...keys: KeyType[]

        Ordered path from outermost to innermost key.

      Returns boolean

      Check whether an entry exists at the given key path.

    • Function

      hasFlat

      Parameters

      • flatKey: string | number

        A flat key produced by flattenKey.

      Returns boolean

      Check whether an entry exists at the given flat key.

    • Function

      hasValue

      Parameters

      Returns boolean

      Check whether the given value exists anywhere in the map.

    • Function

      remove

      Parameters

      • ...keys: KeyType[]

        Ordered path from outermost to innermost key.

      Returns void

      Remove the entry at the given key path.

    • Function

      removeValue

      Parameters

      Returns void

      Remove the first occurrence of the given value.

    • Function

      removeValues

      Parameters

      Returns void

      Remove all occurrences of the given value.

    • Function

      getEntriesAt

      Parameters

      • ...keys: KeyType[]

        Path to the subtree root.

      Returns [KeyType, ValueType][]

      Return all leaf [key, value] pairs under the given path, sorted alphabetically by key. Pass no keys to get all leaf entries in the map.

    • Function

      getKeysAt

      Parameters

      • ...keys: KeyType[]

        Path to the parent node.

      Returns KeyType[]

      Return all leaf keys under the given path, sorted alphabetically. Pass no keys to get all leaf keys in the map.

    • Function

      getValuesAt

      Parameters

      • ...keys: KeyType[]

        Path to the parent node.

      Returns ValueType[]

      Return all leaf values under the given path, sorted alphabetically by key. Pass no keys to get all leaf values in the map.

    • Function

      getPathsAt

      Parameters

      • ...keys: KeyType[]

        Path to the subtree root.

      Returns KeyType[][]

      Return all leaf key paths under the given path. Pass no keys to get all leaf paths in the map.

    • Function

      getSizeAt

      Parameters

      • ...keys: KeyType[]

        Path to the root.

      Returns number

      Return the number of leaf entries under the given path. Pass no keys to get the number of all leaf entries.

    • Function

      flattenKey

      Parameters

      • ...keys: KeyType[]

        The key path to serialize.

      Returns string | number

      The flat key, or undefined if the path is invalid.

      Serialize a key path into a single flat key.

      • Fully numeric paths produce a numeric global leaf index.
      • All other paths produce a "k0|k1|k2|..." string.
    • Function

      scopeKey

      Parameters

      • flatKey: string | number

        The flat key to convert.

      Returns KeyType[]

      The key path, or undefined if conversion fails.

      Convert a flat key back into a key path. Reverses flattenKey.

      • A string "k0|k1|k2" becomes [k0, k1, k2].
      • A numeric global leaf index becomes the corresponding numeric path.
    • Function

      clear

      Returns void

      Remove all entries from the map.

    • Parameters

      • key: any

      Returns string | number