jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.27k stars 506 forks source link

Question: What's the best way to extend a rule? #573

Open nandorojo opened 1 year ago

nandorojo commented 1 year ago

Say I have this rule:

let rule = new RRule({ freq: RRule.WEEKLY })

What's the best way to "edit" the class, preferably immutably?

Should I do this?

let rule = new RRule({ freq: RRule.WEEKLY })

let newRule = new RRule({ ...rule.options, byweekday: [1] })

Thanks!