Class ExtendedMap<K, V>

A Map with additional methods. Similar to that of discord.js's collection

Type Parameters

  • K

  • V

Hierarchy

  • Map<K, V>
    • ExtendedMap

Constructors

  • Type Parameters

    • K

    • V

    Parameters

    • Optional entries: null | readonly (readonly [K, V])[]

    Returns ExtendedMap<K, V>

  • Type Parameters

    • K

    • V

    Parameters

    • Optional iterable: null | Iterable<readonly [K, V]>

    Returns ExtendedMap<K, V>

Properties

[toStringTag]: string
constructor: ExtendedMapConstructor
[species]: MapConstructor

Accessors

  • get size(): number
  • The number of elements in the map. Derived from Map#size.

    Returns number

Methods

  • Returns an iterable of entries in the map.

    Returns IterableIterator<[K, V]>

  • Returns the element of the element at an index of the map. Similar to Array#at().

    Parameters

    • index: number

      The index of the element.

    Returns undefined | V

    The found element, or undefined if no element matches the index.

  • Merges the map with one or more other maps, or a key / value pair. Similar to Array#concat().

    Parameters

    • Rest ...maps: (Map<K, V> | [K, V])[]

      The maps to merge.

    Returns ExtendedMap<K, V>

    The merged map.

  • Removes a specified element from the map. Derived from the Map#delete() method.

    Parameters

    • key: K

      The key of the element to remove.

    Returns boolean

    If the element was removed, false if it does not exist.

  • Returns a new iterator object that contains key value pairs for each element in the map. Derived from the Map#entries() method.

    Returns IterableIterator<[K, V]>

    The new iterator object.

  • Tests if all elements in the map satisfy a test specified in the callback. Similar to Array#every().

    Parameters

    • callbackfn: ((value, key, map) => boolean)

      A function to test every element of the map.

        • (value, key, map): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns boolean

    true if all elements pass the callback test, false otherwise.

  • Creates a new map with all elements that pass a test specified in the callback. Similar to Array#filter().

    Parameters

    • callbackfn: ((value, key, map) => boolean)

      A function to test every element of the map.

        • (value, key, map): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns ExtendedMap<K, V>

    A map with elements that passed the provided test.

  • Returns the first element in the map that satisfies the provided test. Similar to Array#find().

    Parameters

    • callbackfn: ((value, key, map) => boolean)

      A function to test every element of the map.

        • (value, key, map): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns undefined | V

    The first element that satisfies the test. If no element is found, undefined is returned.

  • Returns the first key in the map that satisfies the provided test. Similar to Array#findIndex().

    Parameters

    • callbackfn: ((value, key, map) => boolean)

      A function to test every element of the map.

        • (value, key, map): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns undefined | K

    The first key that satisfies the test. If no element is found, undefined is returned.

  • Returns the first value(s) of the map.

    Returns undefined | V

    The first value if no amount is specified, else an array of the first values.

  • Parameters

    • amount: number

    Returns V[]

  • Returns a new map created by applying a specified callback function to each element of the map, then flattening the result by 1 level. Identical to ExtendedMap#map() followed by flattening by a depth of 1. Similar to Array#flatMap().

    Type Parameters

    • T

    Parameters

    • callbackfn: ((value, key, map) => ExtendedMap<K, T>)

      A function to apply to every element of the map.

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns ExtendedMap<K, T>

    The new map.

  • Executes the provided function once for each element in the map. Derived from the Map#forEach() method, however this is returned instead of void.

    Parameters

    • callbackfn: ((value, key, map) => void)

      The function to execute for each element in the map.

        • (value, key, map): void
        • Parameters

          • value: V
          • key: K
          • map: Map<K, V>

          Returns void

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns ExtendedMap<K, V>

    The map.

  • Returns a specified element from the map. Derived from the Map#get() method.

    Parameters

    • key: K

      The key of the element.

    Returns undefined | V

    The element with the specified key, or undefined if no element matches the key.

  • Checks if the map has an element with the specified key. Derived from the Map#has() method.

    Parameters

    • key: K

      The key to test.

    Returns boolean

    true if an element is found, false otherwise.

  • Creates a string by concatenating the values of all elements of the map.

    Parameters

    • separator: string = ...

      A string to separate values by. Defaults to ,.

    Returns string

    The created strings.

  • Creates a string by concatenating the keys of all elements of the map.

    Parameters

    • separator: string = ...

      A string to separate keys by. Defaults to ,.

    Returns string

    The created strings.

  • Returns a new iterator object that contains keys for each element in the map. Derived from the Map#keys() method.

    Returns IterableIterator<K>

    The new iterator object.

  • Creates an array filled with the results from calling a specified callback function on each element of the map. Similar to Array#map().

    Type Parameters

    • T

    Parameters

    • callbackfn: ((value, key, map) => T)

      A function to apply to every element of the map.

        • (value, key, map): T
        • Parameters

          Returns T

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns T[]

    The array.

  • Executes a specified reducer callback function on each element of the map to produce a single value. Similar to Array#reduce().

    Type Parameters

    • T

    Parameters

    • callbackfn: ((previousValue, currentValue, currentIndex, map) => T)

      A reducer function to apply to every element of the map.

        • (previousValue, currentValue, currentIndex, map): T
        • Parameters

          • previousValue: T
          • currentValue: V
          • currentIndex: K
          • map: ExtendedMap<K, V>

          Returns T

    • Optional initialValue: T

      A value to initialize previousValue in the callback function with.

    Returns T

    The result of the reducer.

  • Adds or modifies an element with the specified key. Derived from the Map#set() method.

    Parameters

    • key: K

      The key of the element to add / modify.

    • value: V

      The new value of the specified element.

    Returns ExtendedMap<K, V>

    The map.

  • Tests if any element in the map satisfies a test specified in the callback. Similar to Array#some().

    Parameters

    • callbackfn: ((value, key, map) => boolean)

      A function to test every element of the map.

        • (value, key, map): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns boolean

    true if a single element passes the callback test, false otherwise.

  • Removes all elements in the map that satisfy a specified test.

    Parameters

    • callbackfn: ((value, key, map) => boolean)

      A function to test every element of the map.

        • (value, key, map): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      A value to use as this when executing callbackfn.

    Returns ExtendedMap<K, V>

    A map containing the removed elements.

  • Returns a new iterator object that contains values for each element in the map. Derived from the Map#values() method.

    Returns IterableIterator<V>

    The new iterator object.

  • Determines if a value is a map.

    Parameters

    • value: any

      The value to test.

    Returns value is Map<any, any>

Generated using TypeDoc