Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Collection<T>

Type parameters

  • T: { id: string | number }

Hierarchy

Index

Constructors

constructor

  • new Collection<T>(baseObject: new (...args: any[]) => T, limit?: number): Collection<T>
  • Type parameters

    • T: { id: string | number }

    Parameters

    • baseObject: new (...args: any[]) => T
        • new (...args: any[]): T
        • Parameters

          • Rest ...args: any[]

          Returns T

    • Optional limit: number

    Returns Collection<T>

Properties

Readonly [toStringTag]

[toStringTag]: string

baseObject

baseObject: new (...args: any[]) => T

Type declaration

    • new (...args: any[]): T
    • Parameters

      • Rest ...args: any[]

      Returns T

Optional limit

limit: number

Readonly size

size: number

Static Readonly [species]

[species]: MapConstructor

Methods

[iterator]

  • [iterator](): IterableIterator<[string | number, T]>
  • Returns an iterable of entries in the map.

    Returns IterableIterator<[string | number, T]>

add

  • add(obj: T, extra?: unknown, replace?: boolean): T
  • Parameters

    • obj: T
    • Optional extra: unknown
    • Optional replace: boolean

    Returns T

clear

  • clear(): void
  • Returns void

delete

  • delete(key: string | number): boolean
  • Parameters

    • key: string | number

    Returns boolean

entries

  • entries(): IterableIterator<[string | number, T]>
  • Returns an iterable of key, value pairs for every entry in the map.

    Returns IterableIterator<[string | number, T]>

every

  • every(func: (i: T) => boolean): boolean
  • Parameters

    • func: (i: T) => boolean
        • (i: T): boolean
        • Parameters

          • i: T

          Returns boolean

    Returns boolean

filter

  • filter(func: (i: T) => boolean): T[]
  • Parameters

    • func: (i: T) => boolean
        • (i: T): boolean
        • Parameters

          • i: T

          Returns boolean

    Returns T[]

find

  • find(func: (i: T) => boolean): undefined | T
  • Parameters

    • func: (i: T) => boolean
        • (i: T): boolean
        • Parameters

          • i: T

          Returns boolean

    Returns undefined | T

forEach

  • forEach(callbackfn: (value: T, key: string | number, map: Map<string | number, T>) => void, thisArg?: any): void
  • Parameters

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

          • value: T
          • key: string | number
          • map: Map<string | number, T>

          Returns void

    • Optional thisArg: any

    Returns void

get

  • get(key: string | number): undefined | T
  • Parameters

    • key: string | number

    Returns undefined | T

has

  • has(key: string | number): boolean
  • Parameters

    • key: string | number

    Returns boolean

keys

  • keys(): IterableIterator<string | number>
  • Returns an iterable of keys in the map

    Returns IterableIterator<string | number>

map

  • map<R>(func: (i: T) => R): R[]
  • Type parameters

    • R

    Parameters

    • func: (i: T) => R
        • (i: T): R
        • Parameters

          • i: T

          Returns R

    Returns R[]

random

  • random(): undefined | T
  • Returns undefined | T

reduce

  • reduce<U>(func: (accumulator: U, val: T) => U, initialValue?: U): U
  • Type parameters

    • U

    Parameters

    • func: (accumulator: U, val: T) => U
        • (accumulator: U, val: T): U
        • Parameters

          • accumulator: U
          • val: T

          Returns U

    • Optional initialValue: U

    Returns U

remove

  • Parameters

    Returns null | T

set

  • set(key: string | number, value: T): Collection<T>
  • Parameters

    • key: string | number
    • value: T

    Returns Collection<T>

some

  • some(func: (i: T) => boolean): boolean
  • Parameters

    • func: (i: T) => boolean
        • (i: T): boolean
        • Parameters

          • i: T

          Returns boolean

    Returns boolean

update

  • update(obj: T, extra?: unknown, replace?: boolean): T
  • Parameters

    • obj: T
    • Optional extra: unknown
    • Optional replace: boolean

    Returns T

values

  • values(): IterableIterator<T>
  • Returns an iterable of values in the map

    Returns IterableIterator<T>

Generated using TypeDoc