Skip to main content

js_parse_int

Function js_parse_int 

Source
pub fn js_parse_int(text: &str) -> f64
Expand description

parseInt(text, 10) (ECMA-262 19.2.5), which is neither str::parse::<i64> nor Go’s strconv.Atoi.

Leading white space is skipped, an optional sign is read, and the longest run of ASCII digits after it is the value: "12abc" is 12, "0x10" is 0 because the scan stops at x, and a string with no digit at all is NaN. The canonical plugin puts the result straight into the parsed feed, so a length or ttl that is not a number becomes a NaN there and a null once the value is rendered as JSON.