parseInt
string
Converts string to an integer of the specified radix.
Installation
Import
import { parseInt } from '@tulx/utils';Source Code
Implementation
/**
* Converts string to an integer of the specified radix.
*
* @param string - The string to convert.
* @param radix - The radix to interpret value by.
* @returns Returns the converted integer.
*
* @example
* ```ts
* parseInt('08'); // 8
* parseInt('10', 2); // 2
* ```
*/
export function parseInt(string: string, radix: number = 10): number {
return Number.parseInt(string, radix);
}
Example
import { parseInt } from '@tulx/utils';
parseInt('08'); // 8
parseInt('10', 2); // 2Related Functions
camelCase
Converts string to camel case.
capitalize
Converts the first character of string to upper case and the remaining to lower case.
deburr
Deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and removing combining diacritical marks.
endsWith
Checks if string ends with the given target string.
escape
Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities.
escapeRegExp
Escapes the RegExp special characters "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.