Represents a class to hold key-value pairs using Collection. This is a extension of [Map] to add Array-like functions and a update builder.

Hierarchy

Constructors

Properties

[toStringTag]: string
constructor: typeof Collection
size: number
[species]: MapConstructor

Accessors

  • get empty(): boolean
  • Returns if this [[Collection]] is empty or not

    Returns boolean

Methods

  • Returns an iterable of entries in the map.

    Returns IterableIterator<[number, Shard]>

  • Returns void

  • Parameters

    • key: number

    Returns boolean

  • Computes a value if it's absent in this Collection

    Parameters

    • key: number

      The key to find

    • insert: Shard | (() => Shard)

      Item to add when it doesn't exist

    Returns Shard

  • Returns an iterable of key, value pairs for every entry in the map.

    Returns IterableIterator<[number, Shard]>

  • Use a predicate function to filter out anything and return a new Array

    Returns

    A new Array of the values that returned true in the predicate function

    Type Parameters

    Parameters

    • predicate: Predicate<ThisArg, Shard, number, number, boolean>

      The predicate function to filter out

    • Optional thisArg: ThisArg

      An additional this context if needed

    Returns Shard[]

  • Use a predicate function to filter out keys and return a new Array of the keys that resolved true in the predicate function. Use Collection#filter to filter out any values from this [[Collection]].

    Returns

    A new Array of the values that returned true in the predicate function

    Type Parameters

    Parameters

    • predicate: Predicate<ThisArg, Shard, number, number, boolean>

      The predicate function to filter out

    • Optional thisArg: ThisArg

      An additional this context if needed

    Returns number[]

  • Find a value in the collection from it's predicate function

    Returns

    The value found or null if not found

    Type Parameters

    Parameters

    • predicate: Predicate<ThisArg, Shard, number, number, boolean>

      The predicate function

    • Optional thisArg: ThisArg

      An additional this context if needed

    Returns null | Shard

  • Finds a key in the collection from it's predicate function

    Returns

    The key found or null if not found

    Type Parameters

    Parameters

    • predicate: MinimalPredicate<ThisArg, Shard, boolean>

      The predicate function

    • Optional thisArg: ThisArg

      An additional this context if needed

    Returns null | number

  • Returns the first element in the collection

    Returns undefined | Shard

  • Returns an Array of the values from the correspondant amount

    Parameters

    • amount: number

      The amount to fetch from

    Returns Shard[]

  • Returns the first key in the collection

    Returns undefined | number

  • Returns an Array of the keys from the correspondant amount

    Parameters

    • amount: number

      The amount to fetch from

    Returns number[]

  • Parameters

    • callbackfn: ((value: Shard, key: number, map: Map<number, Shard>) => void)
        • (value: Shard, key: number, map: Map<number, Shard>): void
        • Parameters

          Returns void

    • Optional thisArg: any

    Returns void

  • Parameters

    • key: number

    Returns undefined | Shard

  • Parameters

    • key: number

    Returns boolean

  • Returns an iterable of keys in the map

    Returns IterableIterator<number>

  • Returns the last element in the collection

    Returns undefined | Shard

  • Returns an Array of the values from the correspondant amount

    Parameters

    • amount: number

      The amount to fetch from

    Returns Shard[]

  • Returns the last element in the collection

    Returns undefined | number

  • Returns an Array of the values from the correspondant amount

    Parameters

    • amount: number

      The amount to fetch from

    Returns number[]

  • Use a predicate function to map anything into a new array

    Returns

    A new Array of the values from that function

    Type Parameters

    Parameters

    • predicate: Predicate<ThisArg, Shard, number, number, S>

      The predicate function to map out and return a new array

    • Optional thisArg: ThisArg

      An additional this context if needed

    Returns S[]

  • Returns a random value from the collection

    Returns

    A random value or null if the collection is empty

    Returns null | Shard

  • Reduce the collection and return a new initial value

    Type Parameters

    • S

    Parameters

    • predicate: ReducePredicate<Collection<number, Shard>, Shard, S, S>

      The predicate function

    • Optional initialValue: S

      The initial value

    Returns S

  • Gets the first item in the collection and removes it (if provided)

    Parameters

    • Optional remove: boolean

      If we should remove it or not

    Returns undefined | Shard

  • Similar to [Array.some], this function tests whether atleast 1 item in the predicate function passes the test in the values cache.

    Returns

    A boolean value if 1 item of the cache is truthy

    Parameters

    • func: ((item: Shard) => boolean)

      The function to use to filter out

        • (item: Shard): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Similar to [Array.some], this functions tests whether atleast 1 key in the predicate function passes the test in the key cache.

    Returns

    A boolean value if 1 item of the cache is truthy

    Parameters

    • func: ((item: number) => boolean)

      The function to use to filter out

        • (item: number): boolean
        • Parameters

          • item: number

          Returns boolean

    Returns boolean

  • Similar to [Array.sort], which basically sorts the values of this Collection to return a value

    Returns

    The value

    Parameters

    Returns Shard[]

  • Similar to [Array.sort], which basically sorts the values of this Collection to return a value

    Returns

    The value

    Parameters

    • compareFn: ((a: number, b: number) => number)

      The compare function

        • (a: number, b: number): number
        • Parameters

          • a: number
          • b: number

          Returns number

    Returns number[]

  • Returns all of the values as an Array

    Returns Shard[]

  • Returns all of the keys as an Array

    Returns number[]

  • Gets the last item in the collection and removes it(if provided)

    Parameters

    • remove: boolean

      If we should remove it or not

    Returns undefined | Shard

  • Returns an iterable of values in the map

    Returns IterableIterator<Shard>