import { RealAny } from "../types/internal"; declare const inspectSymbol: unique symbol; export declare class BaseCollection { protected modifyFn: ((event: 'set' | 'delete' | 'clear', key: any, value: any) => any) | null; protected data: Map; protected maxElements: number; protected allowModify: boolean; /** * Create a new Value Collection * @example * ``` * import { ValueCollection } from "rjweb-server" * * const collection = new ValueCollection() * * collection * .set('name', 'beta') * .set('key', 'value') * * collection.has('key') // true * collection.has('ms') // false * * collection.json() // { name: 'beta', key: 'value' } * * for (const [ key, value ] of collection) { * console.log(key, value) * } * * collection.clear(['key']) * * collection.json() // { key: 'value' } * ``` * @since 2.5.0 */ constructor(data?: Record, parse?: (value: any) => Value, allowModify?: boolean, maxElements?: number); /** * Check if a Key exists * @since 2.5.0 */ has(key: Key): boolean; /** * Get a Key * @since 2.5.0 */ get(key: Key, fallback?: Fallback): Value | Fallback; /** * Search for a Key * @since 9.3.0 */ search(callback: (key: Key, value: Value, index: number) => boolean): [Key, Value] | null; /** * Get all Objects as JSON * @since 2.5.0 * @deprecated use `.json()` instead */ toJSON(excluded?: Key[]): Record; /** * Get the Data of this Collection as JSON * @since 9.3.0 */ json(excluded?: Key[]): Record; /** * Get all Values as Array * @since 2.5.0 * @deprecated use `.values()` instead */ toArray(excluded?: Key[]): Value[]; /** * Get the Values of this Collection * @since 9.3.0 */ values(excluded?: Key[]): Value[]; /** * Get the Keys of this Collection * @since 9.3.0 */ keys(excluded?: Key[]): Key[]; /** * Get the Entries of this Collection * @since 6.0.3 */ entries(excluded?: Key[]): [Key, Value][]; /** * Loop over all Keys * @since 2.5.0 */ forEach(callback: (key: Key, value: Value, index: number) => RealAny, excluded?: Key[]): this; /** * Object Iterator (similar to .forEach() but can be used in for ... of loops) * @since 7.7.0 */ [Symbol.iterator](): Iterator<[Key, Value]>; /** * Map the Keys to a new Array * @since 5.3.1 */ map RealAny>(callback: Callback, excluded?: Key[]): ReturnType[]; /** * The Amount of Stored Objects * @since 2.7.2 * @deprecated use `.size()` instead */ get objectCount(): number; /** * Get the Size of this Collection * @since 9.3.0 */ size(): number; [inspectSymbol](): string; } /** * A Key - Value Store with easy access functions * @example * ``` * const collection = new ValueCollection(...) * ``` * @since 2.5.0 */ export default class ValueCollection extends BaseCollection { /** * Set a Key * @since 2.5.0 */ set(key: Key, value: SetValue): this; /** * Delete a Key * @since 8.0.0 */ delete(key: Key): this; /** * Clear the Stored Objects * @since 3.0.0 */ clear(excluded?: Key[]): number; /** * Import another Value Collection into this one * @since 9.0.0 */ import(data: ValueCollection | Map | IterableIterator<[Key, SetValue]> | [Key, SetValue][]): this; } export {};