export declare type TimeUnits = "years" | "seconds" | "minutes" | "days" | "hours" | "months"; export declare type SumDateRangeProps = { date: Date; value: number; range: TimeUnits; }; export interface PickProps { values: T[]; count: number; } export interface MultipleProps { count: number; generator(index: number): T; } export interface ReplaceSymbolsProps { symbols?: Record; banned?: string[]; } export declare class ChacaUtils { private readonly datatypeModule; /** * Returns one element from an array * * @param list Array of values to return * @example * chaca.utils.oneOfArray([1, 2, 3, 5, 4]) // 3 * chaca.utils.oneOfArray(['Hi!!!', 'Chaca the best!!!', 10]) // 'Chaca the best!!!' * chaca.utils.oneOfArray([]) // undefined */ oneOfArray(list: ReadonlyArray): T; /** * Parses the given string symbol by symbols and replaces the placeholder appropriately. * * - `#` will be replaced with a digit (`0` - `9`). * - `?` will be replaced with an upper letter ('A' - 'Z') * - `$` will be replaced with a lower letter ('a' - 'z') * - `*` will be replaced with either a digit or letter. * * @param text The template string to parse. * @param props.banned values that cannot appear in the string * @param props.symbols object with your own symbol definitions * * @example * chaca.utils.replaceSymbols('#####') // '98441' * chaca.utils.replaceSymbols('?????') // 'ZYRQQ' * chaca.utils.replaceSymbols('***$$') // '4Z3pa' * chaca.utils.replaceSymbols('Your pin is: #?*#?*') // 'Your pin is: 0T85L1' * chaca.utils.replaceSymbols('#####', { banned: ["3", "7", "8"] }) // '91220' * * @returns string */ replaceSymbols(text: string, { banned, symbols: ownSymbols }?: ReplaceSymbolsProps): string; /** * Convert a string to camel case * * @param text string to transform * * @example * chaca.utils.camelCase('Hello World') // 'helloWorld' * chaca.utils.camelCase('hiFriend') // 'hiFriend' * * @returns string */ camelCase(text: string): string; /** * Convert a string to snake case * * @param text string to transform * * @example * chaca.utils.snakeCase('Hello World') // 'hello_world' * chaca.utils.snakeCase('hiFriend') // 'hi_friend' * * @returns string */ snakeCase(text: string): string; /** * Convert a string to dot case * * @param text string to transform * * @example * chaca.utils.dotCase('Hello World') // 'hello.world' * chaca.utils.dotCase('hiFriend') // 'hi.friend' * * @returns string */ dotCase(text: string): string; /** * Convert a string to sentence case * * @param text string to transform * * @example * chaca.utils.sentenceCase('Hello World') // 'Hello world' * chaca.utils.sentenceCase('hiFriend') // 'Hi friend' * * @returns string */ sentenceCase(text: string): string; /** * Convert a string to capital case * * @param text string to transform * * @example * chaca.utils.capitalCase('Hello World') // 'Hello World' * chaca.utils.capitalCase('hiFriend') // 'Hi Friend' * * @returns string */ capitalCase(text: string): string; /** * Convert a string to pascal case * * @param text string to transform * * @example * chaca.utils.pascalCase('Hello World') // 'HelloWorld' * chaca.utils.pascalCase('hiFriend') // 'HiFriend' * * @returns string */ pascalCase(text: string): string; /** * Sum a range value to a date * * @param param.date Date to modify * @param param.range Time unit (`"years"` | `"seconds"` | `"minutes"` | `"days"`| `"hours"` | `"months"`) * @param param.value Amount of time unit * * @returns string */ sumDateRange({ date, range, value }: SumDateRangeProps): Date; /** * Chooses a series of elements from an array of values, preventing an element from being selected more than once * * @param args.values Values array * @param args.count Number of items to select * * @example * chaca.utils.pick({ values: [1, 2, 3, 4, 5], count: 2 }) // [2, 4] * chaca.utils.pick({ values: [1, 2, 3, 4, 5], count: 3 }) // [1, 5, 3] */ pick({ values, count }: PickProps): T[]; /** * Generates an array containing values returned by the given method. * * @param args.count The number of elements to generate. * * @example * chaca.utils.multiple({ generator: () => modules.person.firstName(), count: 3 }) // [ 'Aniya', 'Norval', 'Dallin' ] * chaca.utils.multiple({ generator: () => modules.person.firstName(), count: 3 }) // [ 'Santos', 'Lavinia', 'Lavinia' ] * chaca.utils.multiple({ generator: (i) => `element-${i}`, count: 3 }) // [ 'element-0', 'element-1', 'element-2' ] */ multiple({ generator, count }: MultipleProps): T[]; }