import { Irow, Icolumn, ItableLinks, IretainPage, stringRenderFunc } from "./table-types"; /** * This class helps run minor utilities needed by our application to quickly process * data and get stuff done */ export default class utilsClass { static regex_special: string[]; /** * Performs a left trim as done by * {@link utilsClass.trim} * Thus removing a single or repeating character from the rightmost part of * a string */ static ltrim(trimString: string, regexp: string, replaceWith: string, more?: boolean, allowRegex?: boolean): string; static isInteger(input: any): boolean; /** * Performs a right trim as done by * {@link utilsClass.trim} * Thus removing a single or repeating character from the leftmost part of * a string */ static rtrim(trimString: string, regexp: string, replaceWith: string, more?: boolean, allowRegex?: boolean): string; /** * Trims a sertain character from a string. This does both left and right trimming * * @param trimString The string to be trimmed. * @param regexp A character to remove from the string. * @param replaceWith The character or string to put in place of the replaced string. * @param more if `true`, then it replacement occures for more than a single occurence, else it replaces just * One occurence. ** @param dir Decides if it should be a right or left trim ** @param allowRegex Does not escape input search element * */ static trim(trimString: string, regexp: string, replaceWith: string, more: boolean | undefined, dir: "r" | "l", allowRegex?: boolean): string; /** * A Function to determine if two objects are arrays are equal * * V = value, O= object, O = other,T = Type, OOT = Other Object Type */ static isObjectEqual, OOT extends Record>(value: VT[] | VOT, other: OT[] | OOT): boolean; /** * Compare Primitives, Might be number, string, array , objects or arrays */ static compare, Obj2T extends Record>(item1: string | number | Item1T[] | obj1T, item2: string | number | Item2T[] | Obj2T): boolean; /** * Tests if this given value is even. * @returns {boolean} */ static isEven(value: number): boolean; /** * Internal function used to implement `utilsClass.throttle` and `utilsClass.debounce`. * @param {Function} func: function to be invoked. * @param {number} wait: The amount of milliseconds to wait before executing the said function. * * Borrowed from https://github.com/jashkenas/underscore/commit/9e3e067f5025dbe5e93ed784f93b233882ca0ffe */ static limit(func: D, wait: number, debounce: boolean): (...input: any) => void; /** * Returns a function, that, when invoked, will only be triggered at most once * during a given window of time. * * TODO: allow to set if this callback should be invoked at the * "Beginning" or "End" of the time out * Currently it is invoked at the end */ static throttle: (func: Function, wait: number) => (...input: any) => void; /** * Returns a "function"(rememeber to implement the function), that, * as long as it continues to be invoked, will not * be triggered. The function will be called after it stops being called for * N milliseconds. */ static debounce: (func: Function, wait: number) => (...input: any) => void; static unwindObject(obj: Record, field: string): string; static generateCSV(columns: Icolumn[], items: Irow[], exportModify?: stringRenderFunc): Promise; /** * Recursively stringifies the values of an object, space separated, in an * SSR safe deterministic way (keys are storted before stringification) * * ex: * ```json * { b: 3, * c: { z: 'zzz', d: null, e: 2 }, * d: [10, 12, 11], * a: 'one' * } * ``` * becomes * 'one 3 2 zzz 10 12 11' * * Primatives (numbers/strings) are returned as-is * Null and undefined values are filtered out * Dates are converted to their native string format */ static stringifyObjectValues(val: Record | any): string; static sanitizeRow(row: Irow, columns: Icolumn[]): object; static stringifyRowValues(row: Irow, column: Icolumn[]): string; /** * * Generates a filter function for the search string */ static filterFunction(search_string: string, columns: Icolumn[]): (row: Irow) => boolean; /** * Build the RegExp (no need for global flag, as we only need * to find the value once in the string) * @param {string} str: The input text * @return {RegExp} The returned regex match */ static stringtoRegEx(str: string): RegExp; static RX_SPACES$1: RegExp; static matchMultipleSpace(str: string): string; /** * Borrowed this function from SENTRY(The remote error loggers) * * Escapes special characters, except for whitespace, in a string to be * used inside a regular expression as a string literal. * @param {string} text The string. * @return {string} The escaped string literal. */ static escapeRegExp(text: string): string; /** * This function helps me paginate data and present the paginated data to the table component * * @param {string} rows The rows of data to be paginated. * @param {string} per_page An integer * @param {object} retain_expage_map Recently, I wanted to re-render components while using an updated row data(page_row_array) * but retaining all other property in the page_map. Thus I used this to do keep the * former pagemap I will be getting the data from * @return {ItableLinks} The Final data containing the paginated data and an array of all * pages involved in the pagination i.e 1,2,3,4,5 ..... n */ static TableNumberLinks(rows: Irow[], per_page?: number, retain_expage_map?: IretainPage): ItableLinks; }