/** * IOObject is an ordered key-value collection that supports both keyed and positional access. * * Features: * - Maintains insertion order of key-value pairs * - Supports mixed keyed and positional (keyless) entries * - Provides O(1) key-based lookups via internal Map * - Implements Iterable for for..of loops * - Supports sparse deletions with optional compaction * - Synchronizes with object properties for dot-notation access * * @template T The type of values stored in the object * * @example * ```typescript * const obj = new IOObject(); * obj.set('a', 1); * obj.push(2); // positional entry (no key) * obj.set('b', 3); * console.log(obj.a); // 1 (dot notation) * console.log(obj.getAt(1)); // 2 * ``` */ declare class IOObject implements Iterable<[string | undefined, T]> { [key: string]: any; private items; private keyMap; errors: Error[]; constructor(o?: Record); /** * Adds or updates a key-value pair in the IOObject. * If the key exists, updates the value at its index. * @param key The key to add or update. * @param value The value associated with the key. * @returns The IOObject instance. */ set(key: string, value: T): this; /** * Appends values to the IOObject. * Values can be with or without keys. * @param items Variadic arguments of values or [key, value] pairs. */ push(...items: ([string, T] | T)[]): void; /** * Retrieves the value associated with the given key. * @param key The key to look up. * @returns The value if found, otherwise undefined. */ get(key: string): T | undefined; /** * Retrieves the value at the specified index. * @param index The index to access. * @returns The value if index is valid and entry exists, otherwise undefined. */ getAt(index: number): T | undefined; /** * Retrieves the key at the specified index. * @param index The index to access. * @returns The key if index is valid and exists, otherwise undefined. */ keyAt(index: number): string | undefined; /** * Checks if the IOObject contains a given key. * @param key The key to check. * @returns True if the key exists, otherwise false. */ has(key: string): boolean; /** * Deletes a key-value pair from the IOObject by key. * @param key The key to delete. * @returns True if the key was found and deleted, otherwise false. */ delete(key: string): boolean; /** * Deletes a value at a specific index. * Throws an error if the index is out of range. * @param index The index to delete. * @returns True if the value was deleted, otherwise false. * @throws Error if the index is invalid. */ deleteAt(index: number): boolean; /** * Updates the value at the specified index. * Throws an error if the index is out of range. * @param index The index to set. * @param value The value to set. * @returns True if the value was updated, otherwise false. * @throws Error if the index is invalid. */ setAt(index: number, value: T): boolean; /** * Returns the index of the given key. * @param key The key to find. * @returns The index if found, otherwise -1. */ indexOfKey(key: string): number; /** * Returns the index of the given value. * @param value The value to find. * @returns The index if found, otherwise -1. */ indexOf(value: T): number; /** * Checks if the IOObject is empty. * @returns True if empty, otherwise false. */ isEmpty(): boolean; /** * Creates an IOObject from an array of values or [key, value] pairs. * @param array The array to create from. * @returns A new IOObject instance. */ static fromArray(array: (T | [string, T])[]): IOObject; /** * Returns the number of entries in the IOObject, including undefined entries. */ get length(): number; /** * Clears all key-value pairs from the IOObject. */ clear(): void; /** * Compacts the items array by removing undefined entries and updating the keyMap. * Note: This operation is O(n) and may affect performance on large datasets. * Use this method when you need to reduce memory usage or after multiple deletions. */ compact(): void; /** * Executes a provided function once for each key-value pair. * @param callbackfn Function to execute for each element. * @param thisArg Value to use as `this` when executing callback. */ forEach(callbackfn: (value: T, key: string | undefined, index: number) => void, thisArg?: any): void; /** * Returns an iterable of key, value pairs for every entry in the IOObject. */ entries(): IterableIterator<[string | undefined, T]>; /** * Returns an array of keys in the IOObject. * Excludes entries without keys (i.e., where key is undefined). * @returns An array of keys. */ keysArray(): string[]; /** * Returns an iterable of keys in the IOObject. * Excludes entries without keys (i.e., where key is undefined). */ keys(): IterableIterator; /** * Returns an iterable of values in the IOObject. */ values(): IterableIterator; /** * Returns an array of values in the IOObject. * Includes all entries, even those without keys. * @returns An array of values. */ valuesArray(): T[]; /** * Creates an iterator based on a selector function. * @param selector Function to select the output of the iterator. */ private _createIterator; /** * Returns an iterator over the entries in insertion order. */ [Symbol.iterator](): IterableIterator<[string | undefined, T]>; /** * Returns the default string representation of the object. */ get [Symbol.toStringTag](): string; /** * Finds a value based on a predicate function. * @param predicate Function to test each element. * @returns The value if found, otherwise undefined. */ find(predicate: (value: T, key: string | undefined, index: number) => boolean): T | undefined; /** * Finds the index of a value based on a predicate function. * @param predicate Function to test each element. * @returns The index if found, otherwise -1. */ findIndex(predicate: (value: T, key: string | undefined, index: number) => boolean): number; /** * Creates a new array populated with the results of calling a provided function on every element. * @param callbackfn Function that produces an element of the new Array. * @param thisArg Value to use as `this` when executing callback. * @returns A new array with each element being the result of the callback function. */ map(callbackfn: (value: T, key: string | undefined, index: number) => U, thisArg?: any): U[]; /** * Converts the InternetObject to a plain JavaScript object. * * Logic: * - Recursively calls `toObject()` on child values if they exist. * - Uses keys where available; otherwise uses numeric indices. * * @returns A plain JavaScript object. */ toObject(): any; /** * Alias for toObject(). * Used when calling JSON.stringify. */ toJSON(): any; } export { IOObject as default };