/** * @file src/modules/data/index.ts * @version 2.1.0 * @since 2.0.0 * * @license GPL-3.0-or-later * @copyright Sven Minio 2026 * @author Sven Minio * @category Data * @description * * Central entry point for data manipulation. * * Features a dynamic, overloaded API router that automatically delegates * * to array or object utilities based on the input type. * @requires ./arrays * * Array manipulation methods. * @requires ./objects * * Object manipulation methods. */ import * as arr from './arrays'; import * as obj from './objects'; import { MatchMode } from './types'; /** * * Splits an array or object into smaller chunks (batched processing). * @param data The source array or object. * @param size The maximum size/length of each chunk. * @returns An array containing the chunked arrays or partial objects. */ declare function chunk(array: T[], size: number): T[][]; declare function chunk>(object: T, size: number): Partial[]; /** * * Merges multiple arrays (flat) or objects (deep merge) into a single structure. * @param data The target array or object. * @param args The source arrays or objects to merge. * @returns The newly merged array or modified target object. */ declare function merge(...arrays: any[][]): any[]; declare function merge(target: any, ...sources: any[]): any; /** * * Safely adds an element/property at a specific index without mutating the original structure (Immutable). * @param data The source array or object. * @param arg1 The item to add (array) or the key to add (object). * @param arg2 The index (array) or the value to add (object). * @param arg3 The index (object only). * @returns A new array or object including the added element. */ declare function add(array: T[], item: T, index?: number): T[]; declare function add>(object: T, key: string, value: any, index?: number): T & Record; /** * * Clears the array or object and returns a new empty one (Immutable). * @param data The array or object to clear. * @returns A new empty array `[]` or object `{}`. */ declare function clear(array: T[]): T[]; declare function clear>(object: T): Partial; /** * * Creates a new array or object containing ONLY the specified indices/keys (Allowlist). * @param data The source array or object. * @param keysOrIndices Array of keys (object) or indices (array) to keep. * @returns A new filtered array or object. */ declare function pick(array: T[], indices: number[]): T[]; declare function pick(object: T, keys: K[]): Pick; /** * * Creates a new array or object containing all elements EXCEPT the specified indices/keys (Blocklist). * @param data The source array or object. * @param keysOrIndices Array of keys (object) or indices (array) to remove. * @returns A new filtered array or object. */ declare function omit(array: T[], indices: number[]): T[]; declare function omit(object: T, keys: K[]): Omit; /** * * Safely retrieves a value from a nested array/object structure using dot-notation. * @param data The source array or object. * @param path The path string (e.g., 'settings.theme' or '0.profile.name'). * @returns The found value or undefined if any part is missing. */ declare function get(array: any[], path: string): any; declare function get(object: any, path: string): any; /** * * Sets a value deeply within a nested structure. Creates missing objects/arrays automatically. * @param data The array or object to modify. * @param path The path string (e.g., 'settings.theme'). * @param value The value to set. */ declare function set(array: any[], path: string, value: any): void; declare function set(object: any, path: string, value: any): void; /** * * Removes an entry/element at a specific index (Immutable). * @param data The source array or object. * @param index The index to remove (negative values count from the end). * @returns A new array or object without the specified element. */ declare function removeAt(array: T[], index: number): T[]; declare function removeAt>(object: T, index: number): Partial; /** * * Removes the first entry/element (Immutable). * @param data The source array or object. * @returns A new array or object without the first element. */ declare function removeFirst(array: T[]): T[]; declare function removeFirst>(object: T): Partial; /** * * Removes the last entry/element (Immutable). * @param data The source array or object. * @returns A new array or object without the last element. */ declare function removeLast(array: T[]): T[]; declare function removeLast>(object: T): Partial; /** * * Removes all entries/elements matching a query condition (Immutable). Acts as an inverse filter. * @param data The source array or object. * @param query The search term. * @param mode Comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). * @returns A new array or object containing only the non-matching elements. */ declare function removeByMatch(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T[]; declare function removeByMatch>(object: T, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): Partial; /** * * Removes a specific element by its index (arrays) or key (objects) (Immutable). * @param data The source array or object. * @param keyOrIndex The index or key string to remove. * @returns A new array or object without the specified property/element. */ declare function removeByKey(array: T[], index: number): T[]; declare function removeByKey>(object: T, key: string): Partial; /** * * Removes all elements/entries that match a specific value exactly (Immutable). * @param data The source array or object. * @param value The exact value to remove (strict equality). * @returns A new array or object without the matching values. */ declare function removeByValue(array: T[], value: T): T[]; declare function removeByValue>(object: T, value: any): Partial; /** * * Arrays: Finds the index of the first match. Objects: Returns the n-th [key, value] tuple. * @param data The array or object to search. * @param arg1 Query term (array) or numeric index (object). * @returns The index (array) or tuple (object), or undefined. */ declare function findAt(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): number; declare function findAt(object: any, index: number): [string, any] | undefined; /** * * Returns ALL elements/entries matching the condition. Similar to filter(). * @param data The array or object to search. * @param query The search term. * @param mode Comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). * @returns A new array or partial object containing the matching elements. */ declare function findAll(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T[]; declare function findAll>(object: T, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): Partial; /** * * Returns the FIRST matching element (array) or [key, value] tuple (object). * @param data The array or object to search. * @param query The search term. * @returns The found element/tuple or undefined. */ declare function findFirst(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T | undefined; declare function findFirst(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): [string, any] | undefined; /** * * Returns the LAST matching element (array) or [key, value] tuple (object). Searches in reverse. * @param data The array or object to search. * @param query The search term. * @returns The found element/tuple or undefined. */ declare function findLast(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T | undefined; declare function findLast(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): [string, any] | undefined; /** * * Finds all matching indices (arrays) or keys (objects) based on the query. * @param data The array or object to search. * @param query The search term. * @returns An array of matching stringified keys/indices. */ declare function findKey(array: T[], query: string, mode?: MatchMode): string[]; declare function findKey(object: any, query: string, mode?: MatchMode): string[]; /** * * Finds all matching values within the array or object. * @param data The array or object to search. * @param query The search term. * @returns An array of matching values. */ declare function findValue(array: T[], query: string, mode?: MatchMode): T[]; declare function findValue(object: any, query: string, mode?: MatchMode): any[]; /** * * Finds the index (array) or key (object) of the first match based on the query condition. * @param data The array or object to search. * @param query The search term. * @returns The matching index/key or undefined. */ declare function findByMatch(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): number | undefined; declare function findByMatch(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): string | undefined; /** * * Central data utility object. * * Dynamically routes to array or object methods based on input. * * Backward compatibility for strict calls is maintained via `.arr` and `.obj`. */ export declare const data: { arr: typeof arr; obj: typeof obj; chunk: typeof chunk; merge: typeof merge; add: typeof add; clear: typeof clear; empty: typeof clear; pick: typeof pick; omit: typeof omit; get: typeof get; set: typeof set; remove: { at: typeof removeAt; first: typeof removeFirst; last: typeof removeLast; byKey: typeof removeByKey; byValue: typeof removeByValue; byMatch: typeof removeByMatch; all: typeof clear; }; find: { at: typeof findAt; all: typeof findAll; first: typeof findFirst; last: typeof findLast; key: typeof findKey; value: typeof findValue; byMatch: typeof findByMatch; }; }; export {}; //# sourceMappingURL=index.d.ts.map