Skip to content

Add with helper for immutable rule updates#92

Merged
ggaabe merged 2 commits intomainfrom
codex/add-with-method-to-rruletemporal
Dec 28, 2025
Merged

Add with helper for immutable rule updates#92
ggaabe merged 2 commits intomainfrom
codex/add-with-method-to-rruletemporal

Conversation

@ggaabe
Copy link
Owner

@ggaabe ggaabe commented Dec 28, 2025

Summary

  • add a with() helper to create modified RRuleTemporal instances without mutating originals
  • clone existing options arrays before merging overrides to avoid shared references
  • cover the new behavior with unit tests

Testing

  • npm test

Codex Task


Note

Introduces immutable rule updates and strengthens RSCALE handling.

  • Adds with(updates) to RRuleTemporal, merging updates over cloned option arrays via cloneOptions/cloneUpdateOptions to avoid shared references
  • Caches and enforces non-Gregorian RSCALE calendar support with rscaleCalendarSupport and assertRscaleCalendarSupported, invoked before RSCALE engines
  • New tests: rfc7529_rscale_non_gregorian.test.ts (with calendar support probing) and rrule-temporal.test.ts cases validating with() immutability and rDate/exDate cloning

Written by Cursor Bugbot for commit dee921e. This will update automatically on new commits. Configure here.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1048 to +1052
with(updates: Partial<ManualOpts>): RRuleTemporal {
const merged = {
...this.cloneOptions(),
...updates,
tzid: updates.tzid ?? this.opts.tzid,

Choose a reason for hiding this comment

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

P2 Badge Clone update arrays to keep with() immutable

The new with() helper spreads updates directly into merged, so array fields provided by the caller are stored by reference. This is observable for fields that the constructor does not sanitize/clone (notably rDate and exDate): if a caller does const r = rule.with({rDate}); rDate.push(...), the updated rule’s options mutate after construction, which violates the stated immutability goal and can change subsequent recurrence results. Consider cloning array-valued updates (or specifically rDate/exDate) before constructing the new instance.

Useful? React with 👍 / 👎.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

…lendar support for RSCALE. Enhance tests for immutability of rDate and exDate arrays.
@ggaabe ggaabe merged commit 09d4088 into main Dec 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant