scdate 3.1.0 → 3.2.0

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.
package/README.md CHANGED
@@ -263,6 +263,8 @@ const filteredWeekdays = filterWeekdaysForDates(
263
263
  '2023-12-31',
264
264
  )
265
265
  const updatedWeekdays = addWeekdayToWeekdays(weekdays5, Weekday.Fri) // Add Friday to pattern
266
+ const withoutWednesday = removeWeekdayFromWeekdays(weekdays4, Weekday.Wed) // Remove Wednesday
267
+ const toggled = toggleWeekdayInWeekdays(weekdays2, Weekday.Mon) // Toggle Monday
266
268
 
267
269
  // Weekday navigation
268
270
  const previousDay = getPreviousWeekday(Weekday.Mon) // Returns Weekday.Sun
@@ -142,6 +142,25 @@ export declare const filterWeekdaysForDates: (weekdays: string | SWeekdays, from
142
142
  * @param weekdayToAdd The weekday to add.
143
143
  */
144
144
  export declare const addWeekdayToWeekdays: (weekdays: string | SWeekdays, weekdayToAdd: Weekday) => SWeekdays;
145
+ /**
146
+ * Returns a new SWeekdays instance with the provided weekday removed from the
147
+ * current set of weekdays.
148
+ *
149
+ * @param weekdays The weekdays to remove the weekday from. It can be an
150
+ * SWeekdays or a string in the SMTWTFS format.
151
+ * @param weekdayToRemove The weekday to remove.
152
+ */
153
+ export declare const removeWeekdayFromWeekdays: (weekdays: string | SWeekdays, weekdayToRemove: Weekday) => SWeekdays;
154
+ /**
155
+ * Returns a new SWeekdays instance with the provided weekday toggled. If the
156
+ * weekday is currently included, it is removed. If it is excluded, it is
157
+ * added.
158
+ *
159
+ * @param weekdays The weekdays to toggle the weekday in. It can be an
160
+ * SWeekdays or a string in the SMTWTFS format.
161
+ * @param weekdayToToggle The weekday to toggle.
162
+ */
163
+ export declare const toggleWeekdayInWeekdays: (weekdays: string | SWeekdays, weekdayToToggle: Weekday) => SWeekdays;
145
164
  /**
146
165
  * --- Comparisons ---
147
166
  */
package/dist/sWeekdays.js CHANGED
@@ -215,6 +215,36 @@ export const addWeekdayToWeekdays = (weekdays, weekdayToAdd) => {
215
215
  newWeekdays[weekdayIndex] = getAtIndex(AllWeekdaysIncludedMask, weekdayIndex);
216
216
  return sWeekdays(newWeekdays.join(''));
217
217
  };
218
+ /**
219
+ * Returns a new SWeekdays instance with the provided weekday removed from the
220
+ * current set of weekdays.
221
+ *
222
+ * @param weekdays The weekdays to remove the weekday from. It can be an
223
+ * SWeekdays or a string in the SMTWTFS format.
224
+ * @param weekdayToRemove The weekday to remove.
225
+ */
226
+ export const removeWeekdayFromWeekdays = (weekdays, weekdayToRemove) => {
227
+ const sWeekdaysInstance = sWeekdays(weekdays);
228
+ const newWeekdays = Array.from(sWeekdaysInstance.weekdays);
229
+ const weekdayIndex = getIndexForWeekday(weekdayToRemove);
230
+ newWeekdays[weekdayIndex] = NotIncludedDay;
231
+ return sWeekdays(newWeekdays.join(''));
232
+ };
233
+ /**
234
+ * Returns a new SWeekdays instance with the provided weekday toggled. If the
235
+ * weekday is currently included, it is removed. If it is excluded, it is
236
+ * added.
237
+ *
238
+ * @param weekdays The weekdays to toggle the weekday in. It can be an
239
+ * SWeekdays or a string in the SMTWTFS format.
240
+ * @param weekdayToToggle The weekday to toggle.
241
+ */
242
+ export const toggleWeekdayInWeekdays = (weekdays, weekdayToToggle) => {
243
+ if (doesWeekdaysIncludeWeekday(weekdays, weekdayToToggle)) {
244
+ return removeWeekdayFromWeekdays(weekdays, weekdayToToggle);
245
+ }
246
+ return addWeekdayToWeekdays(weekdays, weekdayToToggle);
247
+ };
218
248
  /**
219
249
  * --- Comparisons ---
220
250
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scdate",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"