MCPcopy
hub / github.com/danvk/dygraphs / parseFloat_

Function parseFloat_

src/dygraph-utils.js:1096–1115  ·  view source on GitHub ↗
(x, opt_line_no, opt_line)

Source from the content-addressed store, hash-verified

1094 * @param {string=} opt_line The text of the line from which the string comes.
1095 */
1096export function parseFloat_(x, opt_line_no, opt_line) {
1097 var val = parseFloat(x);
1098 if (!isNaN(val)) return val;
1099
1100 // Try to figure out what happeend.
1101 // If the value is the empty string, parse it as null.
1102 if (/^ *$/.test(x)) return null;
1103
1104 // If it was actually "NaN", return it as NaN.
1105 if (/^ *nan *$/i.test(x)) return NaN;
1106
1107 // Looks like a parsing error.
1108 var msg = "Unable to parse '" + x + "' as a number";
1109 if (opt_line !== undefined && opt_line_no !== undefined) {
1110 msg += " on line " + (1+(opt_line_no||0)) + " ('" + opt_line + "') of CSV.";
1111 }
1112 console.error(msg);
1113
1114 return null;
1115}
1116
1117// Label constants for the labelsKMB and labelsKMG2 options.
1118// (i.e. '100000' -> '100k')

Callers

nothing calls this directly

Calls 1

parseFloatFunction · 0.85

Tested by

no test coverage detected