UNPKG

@twitchfy/chatbot

Version:

A powerful node module to make your own Twitch ChatBot

59 lines (58 loc) 2.11 kB
/** * A collection of key-value pairs. * @extends Map */ export declare class Collection<T extends string | number | symbol, V> extends Map<T, V> { /** * Creates a new collection. * @param entries The entries to set in the collection. */ constructor(entries?: readonly (readonly [T, V])[] | null); /** * Finds the first value that satisfies the condition. * @param fn The function to execute. * @returns Returns the value if found, otherwise undefined. */ find(fn: (value: V, key: T, collection: this) => boolean): V | undefined; /** * Filters the collection by a condition. * @param fn The function to execute. * @returns The filtered collection. */ filter(fn: (value: V, key: T, collection: this) => boolean): Collection<T, V>; /** * Maps the collection. * @param fn The function to execute. * @returns The mapped collection. */ map<T2>(fn: (value: V, key: T, collection: this) => T2): Collection<T, T2>; /** * Checks if any value satisfies the condition. * @param fn The function to execute. * @returns Whether any value satisfies the condition. */ some(fn: (value: V, key: T, collection: this) => boolean): boolean; /** * Checks if every value satisfies the condition. * @param fn The function to execute. * @returns Whether every value satisfies the condition. */ every(fn: (value: V, key: T, collection: this) => boolean): boolean; /** * Reduces the collection to a single value. * @param fn The function to execute. * @param initial The initial value. * @returns The reduced value. */ reduce<T2>(fn: (accumulator: T2, value: V, key: T, collection: this) => T2, initial: T2): T2; /** * Returns the first value of the collection. * @returns The first value of the collection. */ first(): V | undefined; /** * Transform the collection into an array containing the values of it. * @returns The array containing the values of the collection. */ toArray(): V[]; }