10 examples of 'parsenumber' in JavaScript

Every line of 'parsenumber' 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
this disclaimer
33function parseNumber(parser, leftToken) {
34 const num = Number(leftToken.value);
35 return new NumberExpression(num);
36}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

16function numberParser(params) {
17 return Number(params.newValue);
18}
124function parseNumber(s: string): number {
125 const n = parseFloat(s);
126
127 if (isNaN(n)) {
128 throw new Error(`BillingClient: failed to parse '${s}' as a number`);
129 }
130
131 return n;
132}
3function parseNumber(value) {
4 const num = parseInt(value.toString());
5 if (isNaN(num)) return 0;
6 return num;
7}
15function parseNumber(expr, env) {
16 if (typeof expr === 'number')
17 return expr;
18 return solveExpression(expr, env);
19}
5parse(parser, token) { // eslint-disable-line class-methods-use-this
6 return new NumberExpression(Number(token.value));
7}
210function parseNum(stream) {
211 if (/\D/.test(stream.next)) stream.err("Expected number, got '" + stream.next + "'")
212 let result = Number(stream.next)
213 stream.pos++
214 return result
215}
2export function parse(text: any, roundUp?: any): any {
3 return Number(text);
4}
38protected parseRawNumber(): number {
39 let value = '';
40
41 // Parse integer-part, the leading (+ | - | . | 0-9)
42 while (!this.bytes.done()) {
43 const byte = this.bytes.peek();
44 if (!IsNumeric[byte]) break;
45 value += charFromCode(this.bytes.next());
46 if (byte === CharCodes.Period) break;
47 }
48
49 // Parse decimal-part, the trailing (0-9)
50 while (!this.bytes.done()) {
51 const byte = this.bytes.peek();
52 if (!IsDigit[byte]) break;
53 value += charFromCode(this.bytes.next());
54 }
55
56 const numberValue = Number(value);
57
58 if (!value || !isFinite(numberValue)) {
59 throw new NumberParsingError(this.bytes.position(), value);
60 }
61
62 return numberValue;
63}
32static parse (number) {
33 return new Fixed((number * 256.0) >> 0)
34}

Related snippets