Skip to content

fix(parse): support scientific notation for format() roundtrip#290

Open
leno23 wants to merge 1 commit into
vercel:mainfrom
leno23:fix/parse-scientific-notation-284
Open

fix(parse): support scientific notation for format() roundtrip#290
leno23 wants to merge 1 commit into
vercel:mainfrom
leno23:fix/parse-scientific-notation-284

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

Allow parse() to read scientific notation produced by format() for very large millisecond values.

Problem

Fixes #284. format(Number.MAX_VALUE) yields "5.696545792019405e+297y", but parse() returned NaN because the numeric regex only matched plain decimals.

Fix

Extend the value capture group to accept an optional exponent suffix (e[+-]?\d+). parseFloat() already handles the matched value.

Test plan

  • pnpm test — 170 passed (Node + edge runtime)
  • Scientific notation parse cases (1e3ms, 1.5e2s, -1e3ms, etc.)
  • ms(ms(Number.MAX_VALUE)) roundtrip regression

Extend the numeric capture group to accept exponent suffixes so
parse() can handle strings produced by format() for very large
values like Number.MAX_VALUE.

Fixes vercel#284

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

format() produces output that parse() cannot parse back (roundtrip failure with large numbers)

1 participant