Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: refactor v7 internal state and options logic, fixes #764 #779

Merged
merged 38 commits into from
Jul 18, 2024
Merged

Conversation

broofa
Copy link
Member

@broofa broofa commented Jul 17, 2024

[#776, reopened as a new PR. No idea why it's including so many commits that are already on main]

Putting this PR up as an alternative to #768 that addresses #764 and a few other concerns.

  • Written in Typescript (required now that feat!: Port to TypeScript, closes #762 #763 has landed)
  • Decouple behavior of v7()-with-options from v7()-without-options.
  • Encapsulate internal state handling and refactor to be more idiomatic
  • Rigorous unit tests for internal state transitions
  • Use 32-bit seq field rather than 31.

@robinpokorny My apologies for closing #768. I wanted to merge it, but the switch to typescript and these other issues just made it easier to address in a new PR. I'll do my best to credit your work here.

... and if you could help review this, I'd appreciate it. I feel pretty good about this refactor but there's enough code churn that an extra set of eyes would be very helpful.

Where #764 is concerned, the heart of this PR is in this code, where the behavior very deliberately branches based on whether options are present.

Note

  • 'Marking this as a breaking change because of the changes to default values for options#seq and options#msecs.
  • The v1() code would probably benefit from a similar refactoring, if for nothing else than to make the APIs consistent. I'll put up a PR for that shortly.

Copy link
Contributor

@robinpokorny robinpokorny left a comment

Choose a reason for hiding this comment

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

I really like it now! I think the trade offs are well selected. Good job 🎉

Maybe, in README we should write about the monotonicity and that providing any options means no guarantees of it. WDYT?

@broofa
Copy link
Member Author

broofa commented Jul 18, 2024

@robinpokorny

Maybe, in README we should write about the monotonicity and that providing any options means no guarantees of it. WDYT?

I'll update the README once this PR and #780 land.

@broofa broofa merged commit 9dbd1cd into main Jul 18, 2024
12 checks passed
@broofa broofa deleted the ts_fix_768 branch July 20, 2024 13:17
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