rrule-rust 3.0.0-alpha.4 → 3.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -86,10 +86,6 @@ export class DateTime {
86
86
  static fromNumeric(numeric) {
87
87
  return new DateTime(numeric);
88
88
  }
89
- /** @internal */
90
- static fromPlainOrInstance(datetime) {
91
- return datetime instanceof DateTime ? datetime : this.fromPlain(datetime);
92
- }
93
89
  toPlain(options) {
94
90
  return {
95
91
  year: this.year,
@@ -1,12 +1,12 @@
1
1
  import { RRule, type RRuleLike } from './rrule';
2
2
  import { DateTime, type DateTimeLike } from './datetime';
3
3
  export interface RRuleSetOptions {
4
- readonly dtstart: DateTime | DateTimeLike;
4
+ readonly dtstart: DateTime;
5
5
  readonly tzid?: string;
6
- readonly rrules?: readonly (RRule | RRuleLike)[];
7
- readonly exrules?: readonly (RRule | RRuleLike)[];
8
- readonly exdates?: readonly (DateTime | DateTimeLike)[];
9
- readonly rdates?: readonly (DateTime | DateTimeLike)[];
6
+ readonly rrules?: readonly RRule[];
7
+ readonly exrules?: readonly RRule[];
8
+ readonly exdates?: readonly DateTime[];
9
+ readonly rdates?: readonly DateTime[];
10
10
  }
11
11
  export interface RRuleSetLike {
12
12
  readonly dtstart: DateTimeLike;
@@ -30,16 +30,16 @@ export declare class RRuleSet implements Iterable<DateTime> {
30
30
  */
31
31
  static parse(str: string): RRuleSet;
32
32
  static fromPlain(plain: RRuleSetLike): RRuleSet;
33
- setDtstart(dtstart: DateTime | DateTimeLike): RRuleSet;
33
+ setDtstart(dtstart: DateTime): RRuleSet;
34
34
  setTzid(tzid: string): RRuleSet;
35
- addRrule(rrule: RRule | RRuleLike): RRuleSet;
36
- setRrules(rrules: readonly (RRule | RRuleLike)[]): RRuleSet;
37
- addExrule(rrule: RRule | RRuleLike): RRuleSet;
38
- setExrules(rrules: readonly (RRule | RRuleLike)[]): RRuleSet;
39
- addExdate(datetime: DateTime | DateTimeLike): RRuleSet;
40
- setExdates(datetimes: readonly (DateTime | DateTimeLike)[]): RRuleSet;
41
- addRdate(datetime: DateTime | DateTimeLike): RRuleSet;
42
- setRdates(datetimes: readonly (DateTime | DateTimeLike)[]): RRuleSet;
35
+ addRrule(rrule: RRule): RRuleSet;
36
+ setRrules(rrules: readonly RRule[]): RRuleSet;
37
+ addExrule(rrule: RRule): RRuleSet;
38
+ setExrules(rrules: readonly RRule[]): RRuleSet;
39
+ addExdate(datetime: DateTime): RRuleSet;
40
+ setExdates(datetimes: readonly DateTime[]): RRuleSet;
41
+ addRdate(datetime: DateTime): RRuleSet;
42
+ setRdates(datetimes: readonly DateTime[]): RRuleSet;
43
43
  /**
44
44
  * Returns all the occurrences of the rrule.
45
45
  *
@@ -66,4 +66,5 @@ export declare class RRuleSet implements Iterable<DateTime> {
66
66
  */
67
67
  toPlain(): RRuleSetLike;
68
68
  [Symbol.iterator](): Iterator<DateTime, any, any>;
69
+ private toOptions;
69
70
  }
@@ -6,12 +6,12 @@ export class RRuleSet {
6
6
  if (optionsOrDtstart !== undefined &&
7
7
  !(optionsOrDtstart instanceof DateTime) &&
8
8
  'dtstart' in optionsOrDtstart) {
9
- this.dtstart = DateTime.fromPlainOrInstance(optionsOrDtstart.dtstart);
9
+ this.dtstart = optionsOrDtstart.dtstart;
10
10
  this.tzid = optionsOrDtstart.tzid ?? 'UTC';
11
- this.rrules = (optionsOrDtstart?.rrules ?? []).map(RRule.fromPlainOrInstance.bind(RRule));
12
- this.exrules = (optionsOrDtstart?.exrules ?? []).map(RRule.fromPlainOrInstance.bind(RRule));
13
- this.exdates = (optionsOrDtstart?.exdates ?? []).map(DateTime.fromPlainOrInstance.bind(DateTime));
14
- this.rdates = (optionsOrDtstart?.rdates ?? []).map(DateTime.fromPlainOrInstance.bind(DateTime));
11
+ this.rrules = optionsOrDtstart?.rrules ?? [];
12
+ this.exrules = optionsOrDtstart?.exrules ?? [];
13
+ this.exdates = optionsOrDtstart?.exdates ?? [];
14
+ this.rdates = optionsOrDtstart?.rdates ?? [];
15
15
  }
16
16
  else if (optionsOrDtstart instanceof DateTime) {
17
17
  this.dtstart = optionsOrDtstart;
@@ -33,7 +33,14 @@ export class RRuleSet {
33
33
  return this.fromRust(rust);
34
34
  }
35
35
  static fromPlain(plain) {
36
- return new RRuleSet(plain);
36
+ return new RRuleSet({
37
+ dtstart: DateTime.fromPlain(plain.dtstart),
38
+ tzid: plain.tzid,
39
+ rrules: plain.rrules.map((rrule) => RRule.fromPlain(rrule)),
40
+ exrules: plain.exrules.map((rrule) => RRule.fromPlain(rrule)),
41
+ exdates: plain.exdates.map((datetime) => DateTime.fromPlain(datetime)),
42
+ rdates: plain.rdates.map((datetime) => DateTime.fromPlain(datetime)),
43
+ });
37
44
  }
38
45
  /**
39
46
  * @internal
@@ -52,61 +59,61 @@ export class RRuleSet {
52
59
  }
53
60
  setDtstart(dtstart) {
54
61
  return new RRuleSet({
55
- ...this.toPlain(),
62
+ ...this.toOptions(),
56
63
  dtstart: dtstart,
57
64
  });
58
65
  }
59
66
  setTzid(tzid) {
60
67
  return new RRuleSet({
61
- ...this.toPlain(),
68
+ ...this.toOptions(),
62
69
  tzid: tzid,
63
70
  });
64
71
  }
65
72
  addRrule(rrule) {
66
73
  return new RRuleSet({
67
- ...this.toPlain(),
74
+ ...this.toOptions(),
68
75
  rrules: [...this.rrules, rrule],
69
76
  });
70
77
  }
71
78
  setRrules(rrules) {
72
79
  return new RRuleSet({
73
- ...this.toPlain(),
80
+ ...this.toOptions(),
74
81
  rrules: rrules,
75
82
  });
76
83
  }
77
84
  addExrule(rrule) {
78
85
  return new RRuleSet({
79
- ...this.toPlain(),
86
+ ...this.toOptions(),
80
87
  exrules: [...this.exrules, rrule],
81
88
  });
82
89
  }
83
90
  setExrules(rrules) {
84
91
  return new RRuleSet({
85
- ...this.toPlain(),
92
+ ...this.toOptions(),
86
93
  exrules: rrules,
87
94
  });
88
95
  }
89
96
  addExdate(datetime) {
90
97
  return new RRuleSet({
91
- ...this.toPlain(),
98
+ ...this.toOptions(),
92
99
  exdates: [...this.exdates, datetime],
93
100
  });
94
101
  }
95
102
  setExdates(datetimes) {
96
103
  return new RRuleSet({
97
- ...this.toPlain(),
104
+ ...this.toOptions(),
98
105
  exdates: datetimes,
99
106
  });
100
107
  }
101
108
  addRdate(datetime) {
102
109
  return new RRuleSet({
103
- ...this.toPlain(),
110
+ ...this.toOptions(),
104
111
  rdates: [...this.rdates, datetime],
105
112
  });
106
113
  }
107
114
  setRdates(datetimes) {
108
115
  return new RRuleSet({
109
- ...this.toPlain(),
116
+ ...this.toOptions(),
110
117
  rdates: datetimes,
111
118
  });
112
119
  }
@@ -181,4 +188,14 @@ export class RRuleSet {
181
188
  },
182
189
  };
183
190
  }
191
+ toOptions() {
192
+ return {
193
+ dtstart: this.dtstart,
194
+ tzid: this.tzid,
195
+ rrules: this.rrules,
196
+ exrules: this.exrules,
197
+ exdates: this.exdates,
198
+ rdates: this.rdates,
199
+ };
200
+ }
184
201
  }
@@ -45,7 +45,7 @@ export interface RRuleOptions {
45
45
  readonly frequency: Frequency;
46
46
  readonly interval?: number;
47
47
  readonly count?: number;
48
- readonly until?: DateTime | DateTimeLike;
48
+ readonly until?: DateTime;
49
49
  readonly byWeekday?: readonly (NWeekday | Weekday)[];
50
50
  readonly byHour?: readonly number[];
51
51
  readonly byMinute?: readonly number[];
@@ -108,7 +108,8 @@ export declare class RRule {
108
108
  setByWeekno(weekNumbers: readonly number[]): RRule;
109
109
  setByYearday(days: readonly number[]): RRule;
110
110
  setWeekstart(day: Weekday): RRule;
111
- setUntil(datetime: DateTime | DateTimeLike): RRule;
111
+ setUntil(datetime: DateTime): RRule;
112
112
  toString(): string;
113
113
  toPlain(): RRuleLike;
114
+ private toOptions;
114
115
  }
@@ -79,7 +79,7 @@ export class RRule {
79
79
  return new this({
80
80
  frequency: rrule.frequency,
81
81
  interval: rrule.interval,
82
- until: rrule.until,
82
+ until: rrule.until && DateTime.fromPlain(rrule.until),
83
83
  count: rrule.count,
84
84
  byWeekday: rrule.byWeekday,
85
85
  byHour: rrule.byHour,
@@ -116,53 +116,47 @@ export class RRule {
116
116
  rrule.rust = rust;
117
117
  return rrule;
118
118
  }
119
- /**
120
- * @internal
121
- */
122
- static fromPlainOrInstance(rrule) {
123
- return rrule instanceof RRule ? rrule : this.fromPlain(rrule);
124
- }
125
119
  setFrequency(frequency) {
126
- return new RRule({ ...this.toPlain(), frequency });
120
+ return new RRule({ ...this.toOptions(), frequency });
127
121
  }
128
122
  setInterval(interval) {
129
- return new RRule({ ...this.toPlain(), interval });
123
+ return new RRule({ ...this.toOptions(), interval });
130
124
  }
131
125
  setCount(count) {
132
- return new RRule({ ...this.toPlain(), count });
126
+ return new RRule({ ...this.toOptions(), count });
133
127
  }
134
128
  setByWeekday(weekdays) {
135
- return new RRule({ ...this.toPlain(), byWeekday: weekdays });
129
+ return new RRule({ ...this.toOptions(), byWeekday: weekdays });
136
130
  }
137
131
  setByHour(hours) {
138
- return new RRule({ ...this.toPlain(), byHour: hours });
132
+ return new RRule({ ...this.toOptions(), byHour: hours });
139
133
  }
140
134
  setByMinute(minutes) {
141
- return new RRule({ ...this.toPlain(), byMinute: minutes });
135
+ return new RRule({ ...this.toOptions(), byMinute: minutes });
142
136
  }
143
137
  setBySecond(seconds) {
144
- return new RRule({ ...this.toPlain(), bySecond: seconds });
138
+ return new RRule({ ...this.toOptions(), bySecond: seconds });
145
139
  }
146
140
  setByMonthday(days) {
147
- return new RRule({ ...this.toPlain(), byMonthday: days });
141
+ return new RRule({ ...this.toOptions(), byMonthday: days });
148
142
  }
149
143
  setBySetpos(poses) {
150
- return new RRule({ ...this.toPlain(), bySetpos: poses });
144
+ return new RRule({ ...this.toOptions(), bySetpos: poses });
151
145
  }
152
146
  setByMonth(months) {
153
- return new RRule({ ...this.toPlain(), byMonth: months });
147
+ return new RRule({ ...this.toOptions(), byMonth: months });
154
148
  }
155
149
  setByWeekno(weekNumbers) {
156
- return new RRule({ ...this.toPlain(), byWeekno: weekNumbers });
150
+ return new RRule({ ...this.toOptions(), byWeekno: weekNumbers });
157
151
  }
158
152
  setByYearday(days) {
159
- return new RRule({ ...this.toPlain(), byYearday: days });
153
+ return new RRule({ ...this.toOptions(), byYearday: days });
160
154
  }
161
155
  setWeekstart(day) {
162
- return new RRule({ ...this.toPlain(), weekstart: day });
156
+ return new RRule({ ...this.toOptions(), weekstart: day });
163
157
  }
164
158
  setUntil(datetime) {
165
- return new RRule({ ...this.toPlain(), until: datetime });
159
+ return new RRule({ ...this.toOptions(), until: datetime });
166
160
  }
167
161
  toString() {
168
162
  return this.toRust().toString();
@@ -192,4 +186,22 @@ export class RRule {
192
186
  until: this.until?.toPlain(),
193
187
  };
194
188
  }
189
+ toOptions() {
190
+ return {
191
+ frequency: this.frequency,
192
+ interval: this.interval,
193
+ count: this.count,
194
+ byWeekday: this.byWeekday,
195
+ byHour: this.byHour,
196
+ byMinute: this.byMinute,
197
+ bySecond: this.bySecond,
198
+ byMonthday: this.byMonthday,
199
+ bySetpos: this.bySetpos,
200
+ byMonth: this.byMonth,
201
+ byWeekno: this.byWeekno,
202
+ byYearday: this.byYearday,
203
+ weekstart: this.weekstart,
204
+ until: this.until,
205
+ };
206
+ }
195
207
  }
@@ -89,10 +89,6 @@ class DateTime {
89
89
  static fromNumeric(numeric) {
90
90
  return new DateTime(numeric);
91
91
  }
92
- /** @internal */
93
- static fromPlainOrInstance(datetime) {
94
- return datetime instanceof DateTime ? datetime : this.fromPlain(datetime);
95
- }
96
92
  toPlain(options) {
97
93
  return {
98
94
  year: this.year,
@@ -1,12 +1,12 @@
1
1
  import { RRule, type RRuleLike } from './rrule';
2
2
  import { DateTime, type DateTimeLike } from './datetime';
3
3
  export interface RRuleSetOptions {
4
- readonly dtstart: DateTime | DateTimeLike;
4
+ readonly dtstart: DateTime;
5
5
  readonly tzid?: string;
6
- readonly rrules?: readonly (RRule | RRuleLike)[];
7
- readonly exrules?: readonly (RRule | RRuleLike)[];
8
- readonly exdates?: readonly (DateTime | DateTimeLike)[];
9
- readonly rdates?: readonly (DateTime | DateTimeLike)[];
6
+ readonly rrules?: readonly RRule[];
7
+ readonly exrules?: readonly RRule[];
8
+ readonly exdates?: readonly DateTime[];
9
+ readonly rdates?: readonly DateTime[];
10
10
  }
11
11
  export interface RRuleSetLike {
12
12
  readonly dtstart: DateTimeLike;
@@ -30,16 +30,16 @@ export declare class RRuleSet implements Iterable<DateTime> {
30
30
  */
31
31
  static parse(str: string): RRuleSet;
32
32
  static fromPlain(plain: RRuleSetLike): RRuleSet;
33
- setDtstart(dtstart: DateTime | DateTimeLike): RRuleSet;
33
+ setDtstart(dtstart: DateTime): RRuleSet;
34
34
  setTzid(tzid: string): RRuleSet;
35
- addRrule(rrule: RRule | RRuleLike): RRuleSet;
36
- setRrules(rrules: readonly (RRule | RRuleLike)[]): RRuleSet;
37
- addExrule(rrule: RRule | RRuleLike): RRuleSet;
38
- setExrules(rrules: readonly (RRule | RRuleLike)[]): RRuleSet;
39
- addExdate(datetime: DateTime | DateTimeLike): RRuleSet;
40
- setExdates(datetimes: readonly (DateTime | DateTimeLike)[]): RRuleSet;
41
- addRdate(datetime: DateTime | DateTimeLike): RRuleSet;
42
- setRdates(datetimes: readonly (DateTime | DateTimeLike)[]): RRuleSet;
35
+ addRrule(rrule: RRule): RRuleSet;
36
+ setRrules(rrules: readonly RRule[]): RRuleSet;
37
+ addExrule(rrule: RRule): RRuleSet;
38
+ setExrules(rrules: readonly RRule[]): RRuleSet;
39
+ addExdate(datetime: DateTime): RRuleSet;
40
+ setExdates(datetimes: readonly DateTime[]): RRuleSet;
41
+ addRdate(datetime: DateTime): RRuleSet;
42
+ setRdates(datetimes: readonly DateTime[]): RRuleSet;
43
43
  /**
44
44
  * Returns all the occurrences of the rrule.
45
45
  *
@@ -66,4 +66,5 @@ export declare class RRuleSet implements Iterable<DateTime> {
66
66
  */
67
67
  toPlain(): RRuleSetLike;
68
68
  [Symbol.iterator](): Iterator<DateTime, any, any>;
69
+ private toOptions;
69
70
  }
@@ -9,12 +9,12 @@ class RRuleSet {
9
9
  if (optionsOrDtstart !== undefined &&
10
10
  !(optionsOrDtstart instanceof datetime_1.DateTime) &&
11
11
  'dtstart' in optionsOrDtstart) {
12
- this.dtstart = datetime_1.DateTime.fromPlainOrInstance(optionsOrDtstart.dtstart);
12
+ this.dtstart = optionsOrDtstart.dtstart;
13
13
  this.tzid = optionsOrDtstart.tzid ?? 'UTC';
14
- this.rrules = (optionsOrDtstart?.rrules ?? []).map(rrule_1.RRule.fromPlainOrInstance.bind(rrule_1.RRule));
15
- this.exrules = (optionsOrDtstart?.exrules ?? []).map(rrule_1.RRule.fromPlainOrInstance.bind(rrule_1.RRule));
16
- this.exdates = (optionsOrDtstart?.exdates ?? []).map(datetime_1.DateTime.fromPlainOrInstance.bind(datetime_1.DateTime));
17
- this.rdates = (optionsOrDtstart?.rdates ?? []).map(datetime_1.DateTime.fromPlainOrInstance.bind(datetime_1.DateTime));
14
+ this.rrules = optionsOrDtstart?.rrules ?? [];
15
+ this.exrules = optionsOrDtstart?.exrules ?? [];
16
+ this.exdates = optionsOrDtstart?.exdates ?? [];
17
+ this.rdates = optionsOrDtstart?.rdates ?? [];
18
18
  }
19
19
  else if (optionsOrDtstart instanceof datetime_1.DateTime) {
20
20
  this.dtstart = optionsOrDtstart;
@@ -36,7 +36,14 @@ class RRuleSet {
36
36
  return this.fromRust(rust);
37
37
  }
38
38
  static fromPlain(plain) {
39
- return new RRuleSet(plain);
39
+ return new RRuleSet({
40
+ dtstart: datetime_1.DateTime.fromPlain(plain.dtstart),
41
+ tzid: plain.tzid,
42
+ rrules: plain.rrules.map((rrule) => rrule_1.RRule.fromPlain(rrule)),
43
+ exrules: plain.exrules.map((rrule) => rrule_1.RRule.fromPlain(rrule)),
44
+ exdates: plain.exdates.map((datetime) => datetime_1.DateTime.fromPlain(datetime)),
45
+ rdates: plain.rdates.map((datetime) => datetime_1.DateTime.fromPlain(datetime)),
46
+ });
40
47
  }
41
48
  /**
42
49
  * @internal
@@ -55,61 +62,61 @@ class RRuleSet {
55
62
  }
56
63
  setDtstart(dtstart) {
57
64
  return new RRuleSet({
58
- ...this.toPlain(),
65
+ ...this.toOptions(),
59
66
  dtstart: dtstart,
60
67
  });
61
68
  }
62
69
  setTzid(tzid) {
63
70
  return new RRuleSet({
64
- ...this.toPlain(),
71
+ ...this.toOptions(),
65
72
  tzid: tzid,
66
73
  });
67
74
  }
68
75
  addRrule(rrule) {
69
76
  return new RRuleSet({
70
- ...this.toPlain(),
77
+ ...this.toOptions(),
71
78
  rrules: [...this.rrules, rrule],
72
79
  });
73
80
  }
74
81
  setRrules(rrules) {
75
82
  return new RRuleSet({
76
- ...this.toPlain(),
83
+ ...this.toOptions(),
77
84
  rrules: rrules,
78
85
  });
79
86
  }
80
87
  addExrule(rrule) {
81
88
  return new RRuleSet({
82
- ...this.toPlain(),
89
+ ...this.toOptions(),
83
90
  exrules: [...this.exrules, rrule],
84
91
  });
85
92
  }
86
93
  setExrules(rrules) {
87
94
  return new RRuleSet({
88
- ...this.toPlain(),
95
+ ...this.toOptions(),
89
96
  exrules: rrules,
90
97
  });
91
98
  }
92
99
  addExdate(datetime) {
93
100
  return new RRuleSet({
94
- ...this.toPlain(),
101
+ ...this.toOptions(),
95
102
  exdates: [...this.exdates, datetime],
96
103
  });
97
104
  }
98
105
  setExdates(datetimes) {
99
106
  return new RRuleSet({
100
- ...this.toPlain(),
107
+ ...this.toOptions(),
101
108
  exdates: datetimes,
102
109
  });
103
110
  }
104
111
  addRdate(datetime) {
105
112
  return new RRuleSet({
106
- ...this.toPlain(),
113
+ ...this.toOptions(),
107
114
  rdates: [...this.rdates, datetime],
108
115
  });
109
116
  }
110
117
  setRdates(datetimes) {
111
118
  return new RRuleSet({
112
- ...this.toPlain(),
119
+ ...this.toOptions(),
113
120
  rdates: datetimes,
114
121
  });
115
122
  }
@@ -184,5 +191,15 @@ class RRuleSet {
184
191
  },
185
192
  };
186
193
  }
194
+ toOptions() {
195
+ return {
196
+ dtstart: this.dtstart,
197
+ tzid: this.tzid,
198
+ rrules: this.rrules,
199
+ exrules: this.exrules,
200
+ exdates: this.exdates,
201
+ rdates: this.rdates,
202
+ };
203
+ }
187
204
  }
188
205
  exports.RRuleSet = RRuleSet;
@@ -45,7 +45,7 @@ export interface RRuleOptions {
45
45
  readonly frequency: Frequency;
46
46
  readonly interval?: number;
47
47
  readonly count?: number;
48
- readonly until?: DateTime | DateTimeLike;
48
+ readonly until?: DateTime;
49
49
  readonly byWeekday?: readonly (NWeekday | Weekday)[];
50
50
  readonly byHour?: readonly number[];
51
51
  readonly byMinute?: readonly number[];
@@ -108,7 +108,8 @@ export declare class RRule {
108
108
  setByWeekno(weekNumbers: readonly number[]): RRule;
109
109
  setByYearday(days: readonly number[]): RRule;
110
110
  setWeekstart(day: Weekday): RRule;
111
- setUntil(datetime: DateTime | DateTimeLike): RRule;
111
+ setUntil(datetime: DateTime): RRule;
112
112
  toString(): string;
113
113
  toPlain(): RRuleLike;
114
+ private toOptions;
114
115
  }
@@ -82,7 +82,7 @@ class RRule {
82
82
  return new this({
83
83
  frequency: rrule.frequency,
84
84
  interval: rrule.interval,
85
- until: rrule.until,
85
+ until: rrule.until && datetime_1.DateTime.fromPlain(rrule.until),
86
86
  count: rrule.count,
87
87
  byWeekday: rrule.byWeekday,
88
88
  byHour: rrule.byHour,
@@ -119,53 +119,47 @@ class RRule {
119
119
  rrule.rust = rust;
120
120
  return rrule;
121
121
  }
122
- /**
123
- * @internal
124
- */
125
- static fromPlainOrInstance(rrule) {
126
- return rrule instanceof RRule ? rrule : this.fromPlain(rrule);
127
- }
128
122
  setFrequency(frequency) {
129
- return new RRule({ ...this.toPlain(), frequency });
123
+ return new RRule({ ...this.toOptions(), frequency });
130
124
  }
131
125
  setInterval(interval) {
132
- return new RRule({ ...this.toPlain(), interval });
126
+ return new RRule({ ...this.toOptions(), interval });
133
127
  }
134
128
  setCount(count) {
135
- return new RRule({ ...this.toPlain(), count });
129
+ return new RRule({ ...this.toOptions(), count });
136
130
  }
137
131
  setByWeekday(weekdays) {
138
- return new RRule({ ...this.toPlain(), byWeekday: weekdays });
132
+ return new RRule({ ...this.toOptions(), byWeekday: weekdays });
139
133
  }
140
134
  setByHour(hours) {
141
- return new RRule({ ...this.toPlain(), byHour: hours });
135
+ return new RRule({ ...this.toOptions(), byHour: hours });
142
136
  }
143
137
  setByMinute(minutes) {
144
- return new RRule({ ...this.toPlain(), byMinute: minutes });
138
+ return new RRule({ ...this.toOptions(), byMinute: minutes });
145
139
  }
146
140
  setBySecond(seconds) {
147
- return new RRule({ ...this.toPlain(), bySecond: seconds });
141
+ return new RRule({ ...this.toOptions(), bySecond: seconds });
148
142
  }
149
143
  setByMonthday(days) {
150
- return new RRule({ ...this.toPlain(), byMonthday: days });
144
+ return new RRule({ ...this.toOptions(), byMonthday: days });
151
145
  }
152
146
  setBySetpos(poses) {
153
- return new RRule({ ...this.toPlain(), bySetpos: poses });
147
+ return new RRule({ ...this.toOptions(), bySetpos: poses });
154
148
  }
155
149
  setByMonth(months) {
156
- return new RRule({ ...this.toPlain(), byMonth: months });
150
+ return new RRule({ ...this.toOptions(), byMonth: months });
157
151
  }
158
152
  setByWeekno(weekNumbers) {
159
- return new RRule({ ...this.toPlain(), byWeekno: weekNumbers });
153
+ return new RRule({ ...this.toOptions(), byWeekno: weekNumbers });
160
154
  }
161
155
  setByYearday(days) {
162
- return new RRule({ ...this.toPlain(), byYearday: days });
156
+ return new RRule({ ...this.toOptions(), byYearday: days });
163
157
  }
164
158
  setWeekstart(day) {
165
- return new RRule({ ...this.toPlain(), weekstart: day });
159
+ return new RRule({ ...this.toOptions(), weekstart: day });
166
160
  }
167
161
  setUntil(datetime) {
168
- return new RRule({ ...this.toPlain(), until: datetime });
162
+ return new RRule({ ...this.toOptions(), until: datetime });
169
163
  }
170
164
  toString() {
171
165
  return this.toRust().toString();
@@ -195,5 +189,23 @@ class RRule {
195
189
  until: this.until?.toPlain(),
196
190
  };
197
191
  }
192
+ toOptions() {
193
+ return {
194
+ frequency: this.frequency,
195
+ interval: this.interval,
196
+ count: this.count,
197
+ byWeekday: this.byWeekday,
198
+ byHour: this.byHour,
199
+ byMinute: this.byMinute,
200
+ bySecond: this.bySecond,
201
+ byMonthday: this.byMonthday,
202
+ bySetpos: this.bySetpos,
203
+ byMonth: this.byMonth,
204
+ byWeekno: this.byWeekno,
205
+ byYearday: this.byYearday,
206
+ weekstart: this.weekstart,
207
+ until: this.until,
208
+ };
209
+ }
198
210
  }
199
211
  exports.RRule = RRule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rrule-rust",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.5",
4
4
  "main": "dist/node/index.js",
5
5
  "browser": "dist/browser/index.js",
6
6
  "keywords": [
@@ -96,19 +96,19 @@
96
96
  "prepublishOnly": "npm run build && napi prepublish -t npm"
97
97
  },
98
98
  "optionalDependencies": {
99
- "@rrule-rust/lib-win32-x64-msvc": "3.0.0-alpha.4",
100
- "@rrule-rust/lib-darwin-x64": "3.0.0-alpha.4",
101
- "@rrule-rust/lib-linux-x64-gnu": "3.0.0-alpha.4",
102
- "@rrule-rust/lib-linux-x64-musl": "3.0.0-alpha.4",
103
- "@rrule-rust/lib-linux-arm64-gnu": "3.0.0-alpha.4",
104
- "@rrule-rust/lib-win32-ia32-msvc": "3.0.0-alpha.4",
105
- "@rrule-rust/lib-linux-arm-gnueabihf": "3.0.0-alpha.4",
106
- "@rrule-rust/lib-darwin-arm64": "3.0.0-alpha.4",
107
- "@rrule-rust/lib-android-arm64": "3.0.0-alpha.4",
108
- "@rrule-rust/lib-freebsd-x64": "3.0.0-alpha.4",
109
- "@rrule-rust/lib-linux-arm64-musl": "3.0.0-alpha.4",
110
- "@rrule-rust/lib-win32-arm64-msvc": "3.0.0-alpha.4",
111
- "@rrule-rust/lib-android-arm-eabi": "3.0.0-alpha.4",
112
- "@rrule-rust/lib-wasm32-wasi": "3.0.0-alpha.4"
99
+ "@rrule-rust/lib-win32-x64-msvc": "3.0.0-alpha.5",
100
+ "@rrule-rust/lib-darwin-x64": "3.0.0-alpha.5",
101
+ "@rrule-rust/lib-linux-x64-gnu": "3.0.0-alpha.5",
102
+ "@rrule-rust/lib-linux-x64-musl": "3.0.0-alpha.5",
103
+ "@rrule-rust/lib-linux-arm64-gnu": "3.0.0-alpha.5",
104
+ "@rrule-rust/lib-win32-ia32-msvc": "3.0.0-alpha.5",
105
+ "@rrule-rust/lib-linux-arm-gnueabihf": "3.0.0-alpha.5",
106
+ "@rrule-rust/lib-darwin-arm64": "3.0.0-alpha.5",
107
+ "@rrule-rust/lib-android-arm64": "3.0.0-alpha.5",
108
+ "@rrule-rust/lib-freebsd-x64": "3.0.0-alpha.5",
109
+ "@rrule-rust/lib-linux-arm64-musl": "3.0.0-alpha.5",
110
+ "@rrule-rust/lib-win32-arm64-msvc": "3.0.0-alpha.5",
111
+ "@rrule-rust/lib-android-arm-eabi": "3.0.0-alpha.5",
112
+ "@rrule-rust/lib-wasm32-wasi": "3.0.0-alpha.5"
113
113
  }
114
114
  }