@hebcal/core 6.16.0 → 6.16.1

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.
Files changed (52) hide show
  1. package/README.md +2 -2
  2. package/dist/bundle.js +194 -176
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/bundle.min.js +5 -5
  5. package/dist/bundle.min.js.map +1 -1
  6. package/dist/esm/DailyLearning.js +1 -1
  7. package/dist/esm/HebrewDateEvent.js +1 -1
  8. package/dist/esm/HolidayEvent.js +1 -1
  9. package/dist/esm/KiddushLevanaEvent.js +1 -1
  10. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  11. package/dist/esm/ParshaEvent.js +1 -1
  12. package/dist/esm/TimedEvent.js +1 -1
  13. package/dist/esm/YomKippurKatanEvent.js +1 -1
  14. package/dist/esm/ashkenazi.po.js +1 -1
  15. package/dist/esm/calendar.js +1 -1
  16. package/dist/esm/candles.js +8 -2
  17. package/dist/esm/candles.js.map +1 -1
  18. package/dist/esm/cities.json.js +1 -1
  19. package/dist/esm/event.js +1 -1
  20. package/dist/esm/getStartAndEnd.js +1 -1
  21. package/dist/esm/hallel.js +1 -1
  22. package/dist/esm/he-x-NoNikud.po.js +1 -1
  23. package/dist/esm/he.po.js +1 -1
  24. package/dist/esm/hebcal.js +1 -1
  25. package/dist/esm/holidays.js +1 -1
  26. package/dist/esm/horizon.js +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/isAssurBemlacha.js +1 -1
  29. package/dist/esm/isAveilut.js +1 -1
  30. package/dist/esm/isFastDay.js +1 -1
  31. package/dist/esm/locale.js +1 -1
  32. package/dist/esm/location.js +1 -1
  33. package/dist/esm/modern.js +1 -1
  34. package/dist/esm/molad.js +1 -1
  35. package/dist/esm/moladBase.js +1 -1
  36. package/dist/esm/moladDate.js +1 -1
  37. package/dist/esm/omer.js +2 -11
  38. package/dist/esm/omer.js.map +1 -1
  39. package/dist/esm/parshaName.js +1 -1
  40. package/dist/esm/parshaYear.js +1 -1
  41. package/dist/esm/pkgVersion.d.ts +1 -1
  42. package/dist/esm/pkgVersion.js +2 -2
  43. package/dist/esm/pkgVersion.js.map +1 -1
  44. package/dist/esm/reformatTimeStr.js +1 -1
  45. package/dist/esm/sedra.js +1 -1
  46. package/dist/esm/sefira.json.js +1 -1
  47. package/dist/esm/staticHolidays.js +1 -1
  48. package/dist/esm/string.js +1 -1
  49. package/dist/esm/tachanun.js +1 -1
  50. package/dist/esm/zenith.js +1 -1
  51. package/dist/esm/zmanim.js +1 -1
  52. package/package.json +7 -7
package/README.md CHANGED
@@ -16,7 +16,7 @@ Most work starts with the [`calendar()`](https://hebcal.github.io/api/core/funct
16
16
  function and the [`HDate`](https://hebcal.github.io/api/hdate/classes/HDate.html) class.
17
17
 
18
18
  Nearly everything is available as a standalone function — `calendar()`,
19
- `getHolidaysOnDate()`, `getSedra()`, `tachanun()`, `reformatTimeStr()` — and the
19
+ `getHolidaysOnDate()`, `getSedra()`, `tachanun()`, `hallel()`, `reformatTimeStr()` — and the
20
20
  examples here use that form, since importing only what you need is what lets a
21
21
  bundler drop the rest. The same functions are also reachable as static methods on
22
22
  [`HebrewCalendar`](https://hebcal.github.io/api/core/classes/HebrewCalendar.html).
@@ -26,7 +26,7 @@ Yahrzeits and birthdays are standalone functions too, but they live in
26
26
  `birthdayOrAnniversary()` from there directly.
27
27
  `HebrewCalendar.getYahrzeit()` and `.getBirthdayOrAnniversary()` are thin
28
28
  wrappers over them. A few odds and ends remain class-only:
29
- `eruvTavshilin()`, `hallel()` and `getHolidaysForYear()`.
29
+ `eruvTavshilin()` and `getHolidaysForYear()`.
30
30
 
31
31
  ## Installation
32
32
 
package/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! @hebcal/core v6.16.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
5
5
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
6
- const version = '6.16.0';
6
+ const version = '6.16.1';
7
7
 
8
8
  /*! @hebcal/hdate v0.23.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
9
9
  /**
@@ -8708,8 +8708,25 @@ var citiesJson = [
8708
8708
  "Worcester|US|42.26259|-71.80229|America/New_York|164"
8709
8709
  ];
8710
8710
 
8711
+ // `maxSize` is a count, so a fraction is never meaningful. `Infinity` is allowed as an unbounded cache.
8712
+ // A `maxSize` past `Number.MAX_SAFE_INTEGER` is a count the cache can never reach. It is accepted today, so the check stays `Number.isInteger` instead of narrowing the values `maxSize` accepts.
8713
+ const isValidMaxSize = value => typeof value === 'number'
8714
+ && value > 0
8715
+ // eslint-disable-next-line unicorn/prefer-number-is-safe-integer
8716
+ && (Number.isInteger(value) || value === Infinity);
8717
+
8718
+ // A per-item `maxAge` of `NaN` stores a `NaN` expiry, which means no expiry. Zero is a real expiry, so this must not be a truthiness check.
8719
+ const hasExpiry = item => item.expiry !== undefined && !Number.isNaN(item.expiry);
8720
+
8721
+ // Modes for `#walk()`, by what it yields: a key, a value, a `[key, value]` pair, or the `[key, item]` pair that `evict()` and `resize()` need to act on the captured item.
8722
+ const MODE_KEYS = 0;
8723
+ const MODE_VALUES = 1;
8724
+ const MODE_ENTRIES = 2;
8725
+ const MODE_ITEMS = 3;
8726
+
8727
+ const INVALID_MAX_SIZE_MESSAGE = '`maxSize` must be a whole number greater than 0 or `Infinity`';
8728
+
8711
8729
  class QuickLRU extends Map {
8712
- #size = 0;
8713
8730
  #cache = new Map();
8714
8731
  #oldCache = new Map();
8715
8732
  #maxSize;
@@ -8719,72 +8736,62 @@ class QuickLRU extends Map {
8719
8736
  constructor(options = {}) {
8720
8737
  super();
8721
8738
 
8722
- if (!(options.maxSize && options.maxSize > 0)) {
8723
- throw new TypeError('`maxSize` must be a number greater than 0');
8739
+ if (!isValidMaxSize(options.maxSize)) {
8740
+ throw new TypeError(INVALID_MAX_SIZE_MESSAGE);
8724
8741
  }
8725
8742
 
8726
- if (typeof options.maxAge === 'number' && options.maxAge === 0) {
8743
+ if (typeof options.maxAge === 'number' && !(options.maxAge > 0)) {
8727
8744
  throw new TypeError('`maxAge` must be a number greater than 0');
8728
8745
  }
8729
8746
 
8730
8747
  this.#maxSize = options.maxSize;
8731
- this.#maxAge = options.maxAge || Number.POSITIVE_INFINITY;
8748
+ this.#maxAge = typeof options.maxAge === 'number' ? options.maxAge : Infinity;
8732
8749
  this.#onEviction = options.onEviction;
8733
8750
  }
8734
8751
 
8735
- // For tests.
8736
- get __oldCache() {
8737
- return this.#oldCache;
8738
- }
8739
-
8740
8752
  #emitEvictions(cache) {
8741
8753
  if (typeof this.#onEviction !== 'function') {
8742
8754
  return;
8743
8755
  }
8744
8756
 
8745
- for (const [key, item] of cache) {
8757
+ // A stale copy of a key that was written again is not an eviction, since the key is still in the cache. Filter before notifying, since a callback read can expire the current copy.
8758
+ const evictions = [...cache].filter(([key]) => !this.#cache.has(key) && !this.#oldCache.has(key));
8759
+ for (const [key, item] of evictions) {
8746
8760
  this.#onEviction(key, item.value);
8747
8761
  }
8748
8762
  }
8749
8763
 
8750
8764
  #deleteIfExpired(key, item) {
8751
- if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
8752
- if (typeof this.#onEviction === 'function') {
8765
+ if (hasExpiry(item) && item.expiry <= Date.now()) {
8766
+ // Remove before notifying, so a callback that reads the cache does not see the expired item.
8767
+ const deleted = this.delete(key);
8768
+ if (deleted && typeof this.#onEviction === 'function') {
8753
8769
  this.#onEviction(key, item.value);
8754
8770
  }
8755
8771
 
8756
- return this.delete(key);
8772
+ return deleted;
8757
8773
  }
8758
8774
 
8759
8775
  return false;
8760
8776
  }
8761
8777
 
8762
- #getOrDeleteIfExpired(key, item) {
8763
- const deleted = this.#deleteIfExpired(key, item);
8764
- if (deleted === false) {
8765
- return item.value;
8766
- }
8767
- }
8768
-
8778
+ // Returns the value, or `undefined` once the item has been removed as expired.
8769
8779
  #getItemValue(key, item) {
8770
- return item.expiry ? this.#getOrDeleteIfExpired(key, item) : item.value;
8780
+ return this.#deleteIfExpired(key, item) === false ? item.value : undefined;
8771
8781
  }
8772
8782
 
8773
- #peek(key, cache) {
8774
- const item = cache.get(key);
8775
- return this.#getItemValue(key, item);
8776
- }
8783
+ #set(key, item) {
8784
+ this.#cache.set(key, item);
8777
8785
 
8778
- #set(key, value) {
8779
- this.#cache.set(key, value);
8780
- this.#size++;
8781
-
8782
- if (this.#size >= this.#maxSize) {
8783
- this.#size = 0;
8784
- this.#emitEvictions(this.#oldCache);
8785
- this.#oldCache = this.#cache;
8786
- this.#cache = new Map();
8786
+ if (this.#cache.size < this.#maxSize) {
8787
+ return;
8787
8788
  }
8789
+
8790
+ const oldCache = this.#oldCache;
8791
+ this.#oldCache = this.#cache;
8792
+ this.#cache = new Map();
8793
+ // Emit after the swap, so a throwing callback cannot leave the caches out of sync.
8794
+ this.#emitEvictions(oldCache);
8788
8795
  }
8789
8796
 
8790
8797
  #moveToRecent(key, item) {
@@ -8792,124 +8799,164 @@ class QuickLRU extends Map {
8792
8799
  this.#set(key, item);
8793
8800
  }
8794
8801
 
8795
- * #entriesAscending() {
8796
- for (const item of this.#oldCache) {
8797
- const [key, value] = item;
8802
+ // The current item for `key`, or `undefined` if it is gone or has expired. The recent cache wins, since an old cache copy of a key that is in both is stale. Not a generator, since this runs once per item during iteration.
8803
+ #liveItem(key) {
8804
+ const item = this.#cache.get(key) ?? this.#oldCache.get(key);
8805
+ if (item !== undefined && this.#deleteIfExpired(key, item) === false) {
8806
+ return item;
8807
+ }
8808
+ }
8809
+
8810
+ // The current item for `key`, promoted to the recent cache when it was in the old one, or `undefined` when the key is missing or has expired. Only for the methods that refresh recency, since promoting is what separates them from `peek()`. One lookup per cache, since where the item is found decides the promotion. Not a generator, since this runs once per lookup.
8811
+ #getLiveItem(key) {
8812
+ let item = this.#cache.get(key);
8813
+ if (item === undefined) {
8814
+ item = this.#oldCache.get(key);
8815
+ if (item === undefined || this.#deleteIfExpired(key, item)) {
8816
+ return;
8817
+ }
8818
+
8819
+ this.#moveToRecent(key, item);
8820
+ } else if (this.#deleteIfExpired(key, item)) {
8821
+ return;
8822
+ }
8823
+
8824
+ return item;
8825
+ }
8826
+
8827
+ // The old cache keys that are not also in the recent cache, since an old copy of such a key is stale. A plain loop, since this runs once per item during iteration.
8828
+ #olderKeys() {
8829
+ const keys = [];
8830
+ for (const key of this.#oldCache.keys()) {
8798
8831
  if (!this.#cache.has(key)) {
8799
- const deleted = this.#deleteIfExpired(key, value);
8800
- if (deleted === false) {
8801
- yield item;
8802
- }
8832
+ keys.push(key);
8803
8833
  }
8804
8834
  }
8805
8835
 
8806
- for (const item of this.#cache) {
8807
- const [key, value] = item;
8808
- const deleted = this.#deleteIfExpired(key, value);
8809
- if (deleted === false) {
8810
- yield item;
8836
+ return keys;
8837
+ }
8838
+
8839
+ * #walk(mode, descending) {
8840
+ // Snapshot the keys, so writes during the walk cannot make it visit a key twice or loop forever. The old keys not also in the recent cache come first, then the recent cache, which ascends in recency. Reversing that list is the descending order, so both directions share this loop.
8841
+ const keys = [...this.#olderKeys(), ...this.#cache.keys()];
8842
+ if (descending) {
8843
+ keys.reverse();
8844
+ }
8845
+
8846
+ for (const key of keys) {
8847
+ const item = this.#liveItem(key);
8848
+ if (item === undefined) {
8849
+ continue;
8850
+ }
8851
+
8852
+ // The dispatch is an else-if chain because a `switch` would need a `break` per case inside the walk's loop, which lint flags.
8853
+ // eslint-disable-next-line unicorn/prefer-switch
8854
+ if (mode === MODE_KEYS) {
8855
+ yield key;
8856
+ } else if (mode === MODE_VALUES) {
8857
+ yield item.value;
8858
+ } else if (mode === MODE_ITEMS) {
8859
+ yield [key, item];
8860
+ } else {
8861
+ // MODE_ENTRIES.
8862
+ yield [key, item.value];
8811
8863
  }
8812
8864
  }
8813
8865
  }
8814
8866
 
8867
+ // For tests. Public on purpose, so the test suite can see where an item lives.
8868
+ // eslint-disable-next-line unicorn/prefer-private-class-fields
8869
+ get __oldCache() {
8870
+ return this.#oldCache;
8871
+ }
8872
+
8815
8873
  get(key) {
8816
- if (this.#cache.has(key)) {
8817
- const item = this.#cache.get(key);
8818
- return this.#getItemValue(key, item);
8874
+ const item = this.#getLiveItem(key);
8875
+ return item === undefined ? undefined : item.value;
8876
+ }
8877
+
8878
+ getOrInsert(key, value) {
8879
+ // One lookup, so a stored `undefined` does not pay for a second round, and an item that expires during the call is treated as missing.
8880
+ const item = this.#getLiveItem(key);
8881
+ if (item === undefined) {
8882
+ this.set(key, value);
8883
+ return value;
8819
8884
  }
8820
8885
 
8821
- if (this.#oldCache.has(key)) {
8822
- const item = this.#oldCache.get(key);
8823
- if (this.#deleteIfExpired(key, item) === false) {
8824
- this.#moveToRecent(key, item);
8825
- return item.value;
8826
- }
8886
+ return item.value;
8887
+ }
8888
+
8889
+ getOrInsertComputed(key, callback) {
8890
+ const item = this.#getLiveItem(key);
8891
+ if (item === undefined) {
8892
+ // Only called for a missing key, matching `Map`.
8893
+ const value = callback(key);
8894
+ this.set(key, value);
8895
+ return value;
8827
8896
  }
8897
+
8898
+ return item.value;
8828
8899
  }
8829
8900
 
8830
8901
  set(key, value, {maxAge = this.#maxAge} = {}) {
8831
- const expiry = typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY
8902
+ const expiry = typeof maxAge === 'number' && maxAge !== Infinity
8832
8903
  ? (Date.now() + maxAge)
8833
8904
  : undefined;
8834
8905
 
8835
- if (this.#cache.has(key)) {
8836
- this.#cache.set(key, {
8837
- value,
8838
- expiry,
8839
- });
8840
- } else {
8841
- this.#set(key, {value, expiry});
8842
- }
8906
+ // No lookup is spent telling an existing key from a new one: `#set()` updates a hit in place, since a hit cannot fill the cache, and only an insert can grow it into a rotation. An old cache copy of a re-set key is left in place, stale, and the next rotation drops it.
8907
+ this.#set(key, {value, expiry});
8843
8908
 
8844
8909
  return this;
8845
8910
  }
8846
8911
 
8847
8912
  has(key) {
8848
- if (this.#cache.has(key)) {
8849
- return !this.#deleteIfExpired(key, this.#cache.get(key));
8850
- }
8851
-
8852
- if (this.#oldCache.has(key)) {
8853
- return !this.#deleteIfExpired(key, this.#oldCache.get(key));
8854
- }
8855
-
8856
- return false;
8913
+ const item = this.#cache.get(key) ?? this.#oldCache.get(key);
8914
+ return item !== undefined && !this.#deleteIfExpired(key, item);
8857
8915
  }
8858
8916
 
8859
8917
  peek(key) {
8860
- if (this.#cache.has(key)) {
8861
- return this.#peek(key, this.#cache);
8862
- }
8863
-
8864
- if (this.#oldCache.has(key)) {
8865
- return this.#peek(key, this.#oldCache);
8866
- }
8918
+ const item = this.#cache.get(key) ?? this.#oldCache.get(key);
8919
+ return item === undefined ? undefined : this.#getItemValue(key, item);
8867
8920
  }
8868
8921
 
8869
8922
  expiresIn(key) {
8870
8923
  const item = this.#cache.get(key) ?? this.#oldCache.get(key);
8871
8924
  if (item) {
8872
- return item.expiry ? item.expiry - Date.now() : Number.POSITIVE_INFINITY;
8925
+ return hasExpiry(item) ? item.expiry - Date.now() : Infinity;
8873
8926
  }
8874
8927
  }
8875
8928
 
8876
8929
  delete(key) {
8877
8930
  const deleted = this.#cache.delete(key);
8878
- if (deleted) {
8879
- this.#size--;
8880
- }
8881
-
8882
8931
  return this.#oldCache.delete(key) || deleted;
8883
8932
  }
8884
8933
 
8885
8934
  clear() {
8886
8935
  this.#cache.clear();
8887
8936
  this.#oldCache.clear();
8888
- this.#size = 0;
8889
8937
  }
8890
8938
 
8891
8939
  resize(newSize) {
8892
- if (!(newSize && newSize > 0)) {
8893
- throw new TypeError('`maxSize` must be a number greater than 0');
8940
+ if (!isValidMaxSize(newSize)) {
8941
+ throw new TypeError(INVALID_MAX_SIZE_MESSAGE);
8894
8942
  }
8895
8943
 
8896
- const items = [...this.#entriesAscending()];
8944
+ const items = [...this.#walk(MODE_ITEMS)];
8897
8945
  const removeCount = items.length - newSize;
8898
8946
  if (removeCount < 0) {
8899
8947
  this.#cache = new Map(items);
8900
8948
  this.#oldCache = new Map();
8901
- this.#size = items.length;
8902
8949
  } else {
8903
- if (removeCount > 0) {
8904
- this.#emitEvictions(items.slice(0, removeCount));
8905
- }
8906
-
8907
8950
  this.#oldCache = new Map(items.slice(removeCount));
8908
8951
  this.#cache = new Map();
8909
- this.#size = 0;
8910
8952
  }
8911
8953
 
8912
8954
  this.#maxSize = newSize;
8955
+
8956
+ if (removeCount > 0) {
8957
+ // Emit after the rebuild, so a callback that throws or writes cannot undo it.
8958
+ this.#emitEvictions(items.slice(0, removeCount));
8959
+ }
8913
8960
  }
8914
8961
 
8915
8962
  evict(count = 1) {
@@ -8918,93 +8965,67 @@ class QuickLRU extends Map {
8918
8965
  return;
8919
8966
  }
8920
8967
 
8921
- const items = [...this.#entriesAscending()];
8922
- const evictCount = Math.trunc(Math.min(requested, Math.max(items.length - 1, 0)));
8923
- if (evictCount <= 0) {
8924
- return;
8968
+ // Delete the oldest items where they live. Rebuilding the caches would empty the recent cache, which counts toward the rotation, and repeated calls would then keep deferring the rotation, so the cache would grow without limit.
8969
+ const live = [...this.#walk(MODE_ITEMS)];
8970
+
8971
+ const evictCount = Math.min(Math.trunc(requested), Math.max(live.length - 1, 0));
8972
+ const evicted = [];
8973
+ for (const [key] of live.slice(0, evictCount)) {
8974
+ // A callback during the walk can change the cache, so report the current item, and only if it is still there.
8975
+ const item = this.#cache.get(key) ?? this.#oldCache.get(key);
8976
+ if (item !== undefined && this.delete(key)) {
8977
+ evicted.push([key, item]);
8978
+ }
8925
8979
  }
8926
8980
 
8927
- this.#emitEvictions(items.slice(0, evictCount));
8928
- this.#oldCache = new Map(items.slice(evictCount));
8929
- this.#cache = new Map();
8930
- this.#size = 0;
8981
+ // Emit after the removals, so a callback that throws or writes cannot undo them.
8982
+ this.#emitEvictions(evicted);
8931
8983
  }
8932
8984
 
8933
- * keys() {
8934
- for (const [key] of this) {
8935
- yield key;
8936
- }
8985
+ keys() {
8986
+ return this.#walk(MODE_KEYS);
8937
8987
  }
8938
8988
 
8939
- * values() {
8940
- for (const [, value] of this) {
8941
- yield value;
8942
- }
8989
+ values() {
8990
+ return this.#walk(MODE_VALUES);
8943
8991
  }
8944
8992
 
8945
- * [Symbol.iterator]() {
8946
- for (const item of this.#cache) {
8947
- const [key, value] = item;
8948
- const deleted = this.#deleteIfExpired(key, value);
8949
- if (deleted === false) {
8950
- yield [key, value.value];
8951
- }
8952
- }
8953
-
8954
- for (const item of this.#oldCache) {
8955
- const [key, value] = item;
8956
- if (!this.#cache.has(key)) {
8957
- const deleted = this.#deleteIfExpired(key, value);
8958
- if (deleted === false) {
8959
- yield [key, value.value];
8960
- }
8961
- }
8962
- }
8993
+ [Symbol.iterator]() {
8994
+ // `Map` requires the iterator, `keys()`, `values()` and `entries()` to agree on the order.
8995
+ return this.entriesAscending();
8963
8996
  }
8964
8997
 
8965
- * entriesDescending() {
8966
- let items = [...this.#cache];
8967
- for (let i = items.length - 1; i >= 0; --i) {
8968
- const item = items[i];
8969
- const [key, value] = item;
8970
- const deleted = this.#deleteIfExpired(key, value);
8971
- if (deleted === false) {
8972
- yield [key, value.value];
8973
- }
8974
- }
8975
-
8976
- items = [...this.#oldCache];
8977
- for (let i = items.length - 1; i >= 0; --i) {
8978
- const item = items[i];
8979
- const [key, value] = item;
8980
- if (!this.#cache.has(key)) {
8981
- const deleted = this.#deleteIfExpired(key, value);
8982
- if (deleted === false) {
8983
- yield [key, value.value];
8984
- }
8985
- }
8986
- }
8998
+ entriesDescending() {
8999
+ return this.#walk(MODE_ENTRIES, true);
8987
9000
  }
8988
9001
 
8989
- * entriesAscending() {
8990
- for (const [key, value] of this.#entriesAscending()) {
8991
- yield [key, value.value];
8992
- }
9002
+ entriesAscending() {
9003
+ return this.#walk(MODE_ENTRIES);
8993
9004
  }
8994
9005
 
8995
9006
  get size() {
8996
- if (!this.#size) {
8997
- return this.#oldCache.size;
9007
+ // A key that `set()` wrote again can be in both caches, so count it once. Either cache can be walked for that, so walk the smaller one, and skip the walk entirely while one is still empty.
9008
+ const recentSize = this.#cache.size;
9009
+ const olderSize = this.#oldCache.size;
9010
+ if (recentSize === 0 || olderSize === 0) {
9011
+ return Math.min(recentSize + olderSize, this.#maxSize);
8998
9012
  }
8999
9013
 
9000
- let oldCacheSize = 0;
9001
- for (const key of this.#oldCache.keys()) {
9002
- if (!this.#cache.has(key)) {
9003
- oldCacheSize++;
9014
+ let walked = this.#cache;
9015
+ let checked = this.#oldCache;
9016
+ if (olderSize < recentSize) {
9017
+ walked = this.#oldCache;
9018
+ checked = this.#cache;
9019
+ }
9020
+
9021
+ let duplicates = 0;
9022
+ for (const key of walked.keys()) {
9023
+ if (checked.has(key)) {
9024
+ duplicates++;
9004
9025
  }
9005
9026
  }
9006
9027
 
9007
- return Math.min(this.#size + oldCacheSize, this.#maxSize);
9028
+ return Math.min(recentSize + olderSize - duplicates, this.#maxSize);
9008
9029
  }
9009
9030
 
9010
9031
  get maxSize() {
@@ -13382,7 +13403,13 @@ function makeCandleEvent(ev, hd, options, isFriday, isSaturday) {
13382
13403
  return new HavdalahEvent(hd, mask, time, location, options.havdalahMins, ev, options);
13383
13404
  }
13384
13405
  else {
13385
- mask |= LIGHT_CANDLES$1;
13406
+ // Exactly one of the two candle-lighting flags, chosen by how the time
13407
+ // was computed: LIGHT_CANDLES for minutes before sunset (Shabbat or the
13408
+ // start of a chag), LIGHT_CANDLES_TZEIS for nightfall / Havdalah time
13409
+ // (the second night of Yom Tov, or a chag that begins Saturday night).
13410
+ mask = useHavdalahOffset
13411
+ ? (mask & ~LIGHT_CANDLES$1) | LIGHT_CANDLES_TZEIS$1
13412
+ : (mask & ~LIGHT_CANDLES_TZEIS$1) | LIGHT_CANDLES$1;
13386
13413
  return new CandleLightingEvent(hd, mask, time, location, ev, options);
13387
13414
  }
13388
13415
  }
@@ -13790,16 +13817,7 @@ const sefirot = {
13790
13817
  he: {
13791
13818
  infix: null,
13792
13819
  infix26: null,
13793
- words: [
13794
- '',
13795
- 'חֶֽסֶד',
13796
- 'גְּבוּרָה',
13797
- 'תִּפְאֶֽרֶת',
13798
- 'נֶּֽצַח',
13799
- 'הוֹד',
13800
- 'יְּסוֹד',
13801
- 'מַלְכוּת',
13802
- ],
13820
+ words: ['', 'חֶֽסֶד', 'גְּבוּרָה', 'תִּפְאֶֽרֶת', 'נֶּֽצַח', 'הוֹד', 'יְּסוֹד', 'מַלְכוּת'],
13803
13821
  pfxWords: [
13804
13822
  '',
13805
13823
  'שֶׁבְּחֶֽסֶד',