UNPKG

camote-utils

Version:

A comprehensive TypeScript utility library featuring advanced string and number formatting, data structures, and algorithms

184 lines (183 loc) 9.64 kB
import { GenerateRandomType, GenerateRandomOptions, GenerateRandomStringOptions } from '../random'; export declare class _ { private value; constructor(value: any); valueOf(): any; getValue(): any; removeDuplicates(): this; flattenArray(): this; filterArray(conditionFn: (value: any) => boolean): this; transformArray(transformFn: (value: any) => any): this; implode(arr: any[], delimiter: string): this; capitalizeEach(): this; removeEmptyKeysEntries(): this; deepClone(): this; deepSortAlphabetical(): this; deepCompareObjects(anotherValue: any): this; deepCompare(anotherValue: any): this; deepMerge(anotherValue: any): this; objectToQueryString(): this; objectFilterByKeys(keys: any[]): this; capitalize(): _; slugifyRevert(): _; slugify(): _; truncate(length: number, ellipsis?: string): _; toCamelCase(): _; toKebabCase(): _; mask(str: string, maskChar?: string, visibleCount?: number, position?: 'start' | 'end', active?: boolean): string; explode(delimiter: string, limit?: number): _; toUnicodes(exclude?: string | string[]): _; toHTMLEntities(exclude?: string | string[]): _; swapCase(): _; isDateWithinRange(endDate: Date): _; map(fn: (item: any) => any): _; filter(fn: (item: any) => boolean): _; capitalizeWords(): _; trim(): _; pluralize(count?: number, customPlural?: string): _; formatCurrency(currency?: string, locale?: string): _; formatWithCommas(): _; formatPercentage(decimals?: number): _; static chain(value: any): _; static isNil(value: any): value is null | undefined; static isEmpty(value: any): boolean; static isNumber(value: any): value is number; static isString(value: any): value is string; static isArray(value: any): value is any[]; static isObject(value: any): value is object; static isUrl(value: string): boolean; static isUuid(value: string): boolean; static isAlphanumeric(value: string): boolean; static isEmail(value: string): boolean; static isStrongPassword(value: string): boolean; static isValidTime(value: string): boolean; static isFunction(value: any): value is (...args: any[]) => any; static isDateWithinRange(startDate: Date, endDate: Date): boolean; static isBoolean(str: string): boolean; static isDataView(str: string): boolean; static isNaN(str: string): boolean; static isUndefined(str: string): boolean; static isFinite(str: string): boolean; static isNull(str: string): boolean; static formatCurrency(value: number, currency?: string, locale?: string): string; static formatWithCommas(value: number): string; static formatPercentage(value: number, decimals?: number): string; static formatDecimals(value: number, decimals: number): string; static formatOrdinal(value: number): string; static calculateDiscountPrice(price: number, discount: number): number; static capitalize(str: string): string; static truncate(str: string, length: number, ellipsis?: string): string; static toCamelCase(str: string): string; static toKebabCase(str: string): string; static pad(str: string, length: number, char?: string, position?: 'start' | 'end' | 'both'): string; static mask(str: string, maskChar?: string, visibleCount?: number, position?: 'start' | 'end', active?: boolean): string; static toLowerCase(str: string, substr: string): string; static toUpperCase(str: string, substr: string): string; static chopEnd(str: string, count?: number): string; static chopStart(str: string, count?: number): string; static toHtmlEntities(str: string, exclude?: string | string[]): string; static toUnicodes(str: string, exclude?: string | string[]): string; static swapCase(str: string): string; static generateRandomInteger(min: number, max: number): number; static generateRandomIntegerArray(length: number, min: number, max: number): number[]; static generateRandomIntegerExcluding(min: number, max: number, exclude: number[]): number; static generateRandomString(length: number, options?: GenerateRandomStringOptions): string; static generateRandomPassword(length: number, options?: Omit<GenerateRandomStringOptions, 'lowercase' | 'uppercase' | 'numbers' | 'special'>): string; static generateRandomHexColor(includeHash?: boolean): string; static generateRandom(options: GenerateRandomOptions): number | string | boolean | string[]; static generateRandomHex(includeHash?: boolean): string; static generateRandomColor(format?: 'hex' | 'rgb' | 'hsl'): string; static generateColorPalette(numColors: number, format?: 'hex' | 'rgb' | 'hsl'): string[]; static generateRandomRGB(includeAlpha?: boolean): string | number[]; static generateRandomHSL(includeAlpha?: boolean): string | number[]; static generateUUID(): string; static generateUUIDv4(): string; static humanReadableNumber(value: number, options?: { decimals?: number; compact?: boolean; }): _; static generateStrongPassword: (length: number) => string; } export declare const formatters: { deepClone: <T>(obj: T) => T; deepSortAlphabetical: (input: any, inReverse?: boolean) => any; deepCompare: (objectA: any, objectB: any, returnChanges?: boolean) => boolean | any; deepCompareObjects: (objectA: any, objectB: any, returnChanges?: boolean) => boolean | any; deepMerge: (obj1: { [x: string]: any; }, obj2: { [x: string]: any; }, excluded?: string[]) => { [x: string]: any; }; deepExclude: <T>(sourceArray: T[], valuesToExclude: T[], keySelector?: (value: T) => unknown) => T[]; objectFilterByKeys<T extends Record<string, any>>(data: T, keys: (keyof T)[]): Partial<T>; removeEmptyKeysEntries: (obj: Record<string, any>) => Record<string, any>; objectToQueryString: (obj: Record<string, any> | Array<Array<any>> | Array<any>) => string; removeDuplicates: <T>(arr: T[]) => T[]; flattenArray: <T>(arr: T[][]) => T[]; filterArray: <T>(arr: T[], conditionFn: (value: T) => boolean) => T[]; transformArray: <T, U>(arr: T[], transformFn: (value: T) => U) => U[]; capitalizeEach: (array: string[]) => string[]; implode: <T>(arr: T[], delimiter?: string) => string; isDateWithinRange: (startDate: Date | null, endDate: Date | null, date?: Date | null) => boolean; capitalize: (str: string) => string; truncate: (str: string, length: number, ellipsis?: string) => string; toCamelCase: (str: string) => string; toKebabCase: (str: string) => string; toSnakeCase: (str: string) => string; slugify: (str: string) => string; slugifyRevert: (str: string) => string; wordCount: (str: string) => number; format: (template: string, values: Record<string, string | number>) => string; reverse: (str: string) => string; clean: (str: string) => string; pluralize: (word: string, count?: number, customPlural?: string) => string; toUpperCase: (str: string, locale?: string) => string; toLowerCase: (str: string, locale?: string) => string; chopStart: (str: string, count?: number) => string; chopEnd: (str: string, count?: number) => string; capitalizeWords: (str: string) => string; mask: (str: string, maskChar?: string, visibleCount?: number, position?: "start" | "end", active?: boolean) => string; pad: (str: string, length: number, char?: string, position?: "start" | "end" | "both") => string; trim: (str: string) => string; explode: (str: string, delimiter: string, limit?: number) => string[]; toUnicodes: (str: string, exclude?: string | string[]) => string; toHtmlEntities: (str: string, exclude?: string | string[]) => string; swapCase: (str: string) => string; humanReadableNumber: (num: number, options?: { decimals?: number; compact?: boolean; }) => string; formatWithCommas: (num: number) => string; formatPercentage: (num: number, decimals?: number) => string; formatOrdinal: (num: number) => string; formatFileSize: (bytes: number, decimals?: number) => string; formatCurrency: (amount: number, currency?: string, locale?: string) => string; formatDecimals: (num: number, decimals: number, roundingMode?: "ceil" | "floor" | "round") => string; calculateDiscountPrice: (originalPrice: number, discountAmount: number, discountType?: "%" | "$") => number; }; export declare const checks: { isNil: (value: any) => value is null | undefined; isEmpty: (value: any) => boolean; isNumber: (value: any) => value is number; isString: (value: any) => value is string; isArray: <T>(value: any) => value is T[]; isObject: (value: any) => value is object; isUrl: (str: string) => boolean; isUuid: (str: string) => boolean; contains: (str: string, substring: string, caseSensitive?: boolean) => boolean; exactly: (str: string, match: string, caseSensitive?: boolean) => boolean; isBoolean: (value: any) => value is boolean; isFunction: (value: any) => value is Function; isDataView: (value: any) => value is DataView; isNaN: (value: any) => boolean; isNull: (value: any) => value is null; isUndefined: (value: any) => value is undefined; isFinite: (value: any) => boolean; isAlphanumeric: (str: string) => boolean; isEmail: (str: string) => boolean; isStrongPassword: (password: string) => boolean; isValidTime: (timeString: string) => boolean; }; export type { GenerateRandomType, GenerateRandomOptions, GenerateRandomStringOptions };