UNPKG

direct-helpers

Version:
212 lines (207 loc) 8.69 kB
/** * Capitalizes the first letter of a string * @param {string} str - The string to capitalize * @returns {string} The capitalized string */ declare const capitalize: (str: string) => string; /** * Capitalizes the first letter of each word in a string * @param {string} str - The string to capitalize * @returns {string} The capitalized string */ declare const capitalizeWords: (str: string) => string; /** * Counts the number of words in a string * @param {string} str - The string to count words in * @returns {number} The number of words in the string */ declare const countWords: (str: string) => number; /** * Counts the number of characters in a string * @param {string} str - The string to count characters in * @param {boolean} countWhitespace - Whether to count whitespace characters * @returns {number} The number of characters in the string */ declare const countCharacters: (str: string, countWhitespace?: boolean) => number; /** * Converts a string to camel case * @param {string} str - The string to convert to camel case * @returns {string} The camel case string */ declare const toCamelCase: (str: string) => string; /** * Converts a string to kebab case * @param {string} str - The string to convert to kebab case * @returns {string} The kebab case string */ declare const toKebabCase: (str: string) => string; /** * Converts a string to snake case * @param {string} str - The string to convert to snake case * @returns {string} The snake case string */ declare const toSnakeCase: (str: string) => string; /** * Converts a string to title case * @param {string} str - The string to convert to title case * @returns {string} The title case string */ declare const toTitleCase: (str: string) => string; /** * Generates a password with a specific length * @param {number} length - The length of the password * @param {boolean} includeSymbols - Whether to include symbols in the password * @returns {string} The generated password */ declare const generatePassword: (length: number, includeSymbols?: boolean) => string; declare const index$1_capitalize: typeof capitalize; declare const index$1_capitalizeWords: typeof capitalizeWords; declare const index$1_countCharacters: typeof countCharacters; declare const index$1_countWords: typeof countWords; declare const index$1_generatePassword: typeof generatePassword; declare const index$1_toCamelCase: typeof toCamelCase; declare const index$1_toKebabCase: typeof toKebabCase; declare const index$1_toSnakeCase: typeof toSnakeCase; declare const index$1_toTitleCase: typeof toTitleCase; declare namespace index$1 { export { index$1_capitalize as capitalize, index$1_capitalizeWords as capitalizeWords, index$1_countCharacters as countCharacters, index$1_countWords as countWords, index$1_generatePassword as generatePassword, index$1_toCamelCase as toCamelCase, index$1_toKebabCase as toKebabCase, index$1_toSnakeCase as toSnakeCase, index$1_toTitleCase as toTitleCase }; } /** * Capitalizes the first letter of a string * @param {number} min - The minimum number * @param {number} max - The maximum number * @returns {number} The random number */ declare const getRandomNumber: (min: number, max: number) => number; /** * Get a random OTP * @param {number} length - The length of the OTP * @param {boolean} alphaNumeric - Whether the OTP should be alphanumeric * @returns {string} The OTP */ declare const getOtp: (length?: number, alphaNumeric?: boolean) => string; /** * Count the percentage of a part of a total * @param {number} part - The part of the total * @param {number} total - The total * @param {number} precision - The precision of the percentage * @returns {number} The percentage */ declare const countPercentage: (part: number, total: number, precision?: number) => number; /** * Check if a number is even * @param {number} number - The number to check * @returns {boolean} Whether the number is even */ declare const isEven: (number: number) => boolean; /** * Check if a number is odd * @param {number} number - The number to check * @returns {boolean} Whether the number is odd */ declare const isOdd: (number: number) => boolean; /** * Check if a number is prime * @param {number} number - The number to check * @returns {boolean} Whether the number is prime */ declare const isPrime: (number: number) => boolean; /** * Check if a number is a palindrome * @param {number} number - The number to check * @returns {boolean} Whether the number is a palindrome */ declare const isPalindrome: (number: number) => boolean; /** * Check if a number is a perfect square * @param {number} number - The number to check * @returns {boolean} Whether the number is a perfect square */ declare const isPerfectSquare: (number: number) => boolean; /** * Check if a number is a perfect cube * @param {number} number - The number to check * @returns {boolean} Whether the number is a perfect cube */ declare const isPerfectCube: (number: number) => boolean; /** * Square a number * @param {number} number - The number to square * @returns {number} The squared number */ declare const square: (number: number) => number; /** * Cube a number * @param {number} number - The number to cube * @returns {number} The cubed number */ declare const cube: (number: number) => number; /** * Square root a number * @param {number} number - The number to square root * @returns {number} The square rooted number */ declare const squareRoot: (number: number) => number; /** * Cube root a number * @param {number} number - The number to cube root * @returns {number} The cube rooted number */ declare const cubeRoot: (number: number) => number; /** * Factorial a number * @param {number} number - The number to factorial * @returns {number} The factorialed number */ declare const factorial: (number: number) => number; /** * Check if a number is a power of 2 * @param {number} number - The number to check * @returns {boolean} Whether the number is a power of 2 */ declare const isPowerOfTwo: (number: number) => boolean; /** * Check if a number is a power of 3 * @param {number} number - The number to check * @returns {boolean} Whether the number is a power of 3 */ declare const isPowerOfThree: (number: number) => boolean; /** * Round a number to a specific precision * @param {number} number - The number to round * @param {number} precision - The precision to round to * @returns {number} The rounded number */ declare const roundTo: (number: number, precision: number) => number; /** * Formats a number into a string with metric suffixes (K, M, B, T) * and rounds it to a specific precision. * K = Thousand (1e3), M = Million (1e6), B = Billion (1e9), T = Trillion (1e12). * * @param {number} number - The number to format. * @param {number} precision - The number of decimal places to show (non-negative integer). * @returns {string} The formatted number string (e.g., "12.50K", "1.235M", "500.00"). */ declare const formatNumberWithSuffix: (number: number, precision: number) => string; declare const index_countPercentage: typeof countPercentage; declare const index_cube: typeof cube; declare const index_cubeRoot: typeof cubeRoot; declare const index_factorial: typeof factorial; declare const index_formatNumberWithSuffix: typeof formatNumberWithSuffix; declare const index_getOtp: typeof getOtp; declare const index_getRandomNumber: typeof getRandomNumber; declare const index_isEven: typeof isEven; declare const index_isOdd: typeof isOdd; declare const index_isPalindrome: typeof isPalindrome; declare const index_isPerfectCube: typeof isPerfectCube; declare const index_isPerfectSquare: typeof isPerfectSquare; declare const index_isPowerOfThree: typeof isPowerOfThree; declare const index_isPowerOfTwo: typeof isPowerOfTwo; declare const index_isPrime: typeof isPrime; declare const index_roundTo: typeof roundTo; declare const index_square: typeof square; declare const index_squareRoot: typeof squareRoot; declare namespace index { export { index_countPercentage as countPercentage, index_cube as cube, index_cubeRoot as cubeRoot, index_factorial as factorial, index_formatNumberWithSuffix as formatNumberWithSuffix, index_getOtp as getOtp, index_getRandomNumber as getRandomNumber, index_isEven as isEven, index_isOdd as isOdd, index_isPalindrome as isPalindrome, index_isPerfectCube as isPerfectCube, index_isPerfectSquare as isPerfectSquare, index_isPowerOfThree as isPowerOfThree, index_isPowerOfTwo as isPowerOfTwo, index_isPrime as isPrime, index_roundTo as roundTo, index_square as square, index_squareRoot as squareRoot }; } export { index as numberUtils, index$1 as stringUtils };