Repository navigation
fix: support exponential notation in parse. - #301
mahatabnehal wants to merge 1 commit into
Conversation
agammann
left a comment
There was a problem hiding this comment.
This revision cannot be imported because the new regex literal spans lines. The unit alternatives also drop existing month inputs. I left a focused note and a control for each problem.
| str, | ||
| ); | ||
|
|
||
| /^(?<value>-?\d*\.?\d+(?:e[+-]?\d+)?) |
There was a problem hiding this comment.
The regex literal is split across physical lines here, so the module fails to parse before parse() can run. At this head, importing src/index.ts on Node 24 throws ERR_INVALID_TYPESCRIPT_SYNTAX: Unterminated regexp literal at line 78. Please keep the regex and .exec(str) expression syntactically intact and add a test for the exponential input.
| ); | ||
|
|
||
| /^(?<value>-?\d*\.?\d+(?:e[+-]?\d+)?) | ||
| *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i.exec(s |
There was a problem hiding this comment.
The existing months?|mo alternatives are missing from this new unit group. On current main, parse("1mo"), parse("1 month"), and parse("1 months") each return 2629800000; after the syntax error is repaired, this regex would no longer match those inputs. Please retain the month alternatives and add a regression test.
No description provided.