Skip to content

fix: support exponential notation in parse. - #301

Open
mahatabnehal wants to merge 1 commit into
vercel:mainfrom
mahatabnehal:main
Open

mahatabnehal wants to merge 1 commit into
vercel:mainfrom
mahatabnehal:main

Conversation

@mahatabnehal

Copy link
Copy Markdown

No description provided.

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/index.ts
str,
);

/^(?<value>-?\d*\.?\d+(?:e[+-]?\d+)?)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/index.ts
);

/^(?<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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants