4 examples of 'parseint radix' in JavaScript

Every line of 'parseint radix' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
12function toInt(str, radix) {
13 (0, _assertString.default)(str);
14 return parseInt(str, radix || 10);
15}
44export function parse_int(inputString: string, radix: number) {
45 const parsed = parseInt(inputString, radix)
46 if (inputString && radix && parsed) {
47 // the two arguments are provided, and parsed is not NaN
48 return parsed
49 } else {
50 throw new Error('parseInt expects two arguments a string s, and a positive integer i')
51 }
52}
55function isValidRadix(radix) {
56 return !(
57 (radix.type === "Literal" && typeof radix.value !== "number") ||
58 (radix.type === "Identifier" && radix.name === "undefined")
59 );
60}
31function parseInt(string, radix, guard) {
32 if (guard || radix == null) {
33 radix = 0;
34 } else if (radix) {
35 radix = +radix;
36 }
37 return nativeParseInt(toString(string), radix || 0);
38}

Related snippets