fix(parse): support scientific notation for format() roundtrip#290
Open
leno23 wants to merge 1 commit into
Open
fix(parse): support scientific notation for format() roundtrip#290leno23 wants to merge 1 commit into
leno23 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow
parse()to read scientific notation produced byformat()for very large millisecond values.Problem
Fixes #284.
format(Number.MAX_VALUE)yields"5.696545792019405e+297y", butparse()returnedNaNbecause 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)1e3ms,1.5e2s,-1e3ms, etc.)ms(ms(Number.MAX_VALUE))roundtrip regression