Returning `NaN` instead of `null` sounds good, along with an update of this comment, e.g. `Return a Number or NaN when value is invalid.`

We should only throw exceptions for something like invalid patterns, not for something that is likely to be user input, e.g. from a form input.