@hebcal/core 6.15.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 (62) hide show
  1. package/README.md +2 -2
  2. package/dist/bundle.js +298 -228
  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.d.ts +1 -1
  9. package/dist/esm/HolidayEvent.js +3 -3
  10. package/dist/esm/HolidayEvent.js.map +1 -1
  11. package/dist/esm/KiddushLevanaEvent.js +1 -1
  12. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  13. package/dist/esm/ParshaEvent.js +2 -2
  14. package/dist/esm/ParshaEvent.js.map +1 -1
  15. package/dist/esm/TimedEvent.js +1 -1
  16. package/dist/esm/YomKippurKatanEvent.js +1 -1
  17. package/dist/esm/ashkenazi.po.js +1 -1
  18. package/dist/esm/calendar.js +1 -1
  19. package/dist/esm/candles.js +8 -2
  20. package/dist/esm/candles.js.map +1 -1
  21. package/dist/esm/cities.json.js +1 -1
  22. package/dist/esm/event.js +1 -1
  23. package/dist/esm/getStartAndEnd.js +1 -1
  24. package/dist/esm/hallel.d.ts +26 -3
  25. package/dist/esm/hallel.js +86 -29
  26. package/dist/esm/hallel.js.map +1 -1
  27. package/dist/esm/he-x-NoNikud.po.js +1 -1
  28. package/dist/esm/he.po.js +1 -1
  29. package/dist/esm/hebcal.d.ts +3 -9
  30. package/dist/esm/hebcal.js +6 -16
  31. package/dist/esm/hebcal.js.map +1 -1
  32. package/dist/esm/holidays.js +1 -1
  33. package/dist/esm/horizon.js +1 -1
  34. package/dist/esm/index.d.ts +1 -0
  35. package/dist/esm/index.js +2 -1
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/isAssurBemlacha.js +1 -1
  38. package/dist/esm/isAveilut.js +1 -1
  39. package/dist/esm/isFastDay.js +1 -1
  40. package/dist/esm/locale.js +1 -1
  41. package/dist/esm/location.js +1 -1
  42. package/dist/esm/modern.js +1 -1
  43. package/dist/esm/molad.js +1 -1
  44. package/dist/esm/moladBase.js +1 -1
  45. package/dist/esm/moladDate.js +1 -1
  46. package/dist/esm/omer.d.ts +4 -0
  47. package/dist/esm/omer.js +7 -12
  48. package/dist/esm/omer.js.map +1 -1
  49. package/dist/esm/parshaName.js +1 -1
  50. package/dist/esm/parshaYear.js +1 -1
  51. package/dist/esm/pkgVersion.d.ts +1 -1
  52. package/dist/esm/pkgVersion.js +2 -2
  53. package/dist/esm/pkgVersion.js.map +1 -1
  54. package/dist/esm/reformatTimeStr.js +1 -1
  55. package/dist/esm/sedra.js +1 -1
  56. package/dist/esm/sefira.json.js +1 -1
  57. package/dist/esm/staticHolidays.js +1 -1
  58. package/dist/esm/string.js +1 -1
  59. package/dist/esm/tachanun.js +1 -1
  60. package/dist/esm/zenith.js +1 -1
  61. package/dist/esm/zmanim.js +1 -1
  62. package/package.json +7 -7
package/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! @hebcal/core v6.15.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.15.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() {
@@ -11690,7 +11711,7 @@ class HolidayEvent extends Event {
11690
11711
  /**
11691
11712
  * Returns a `https://www.hebcal.com/holidays/...` URL for more detail on
11692
11713
  * this holiday. Israel-only holidays get an `?i=on` query parameter.
11693
- * Returns `undefined` for years outside `[100, 2999]` and for
11714
+ * Returns `undefined` for Gregorian years outside `[1752, 2499]` and for
11694
11715
  * Ta'anit BeHaB, which has no holiday page.
11695
11716
  */
11696
11717
  url() {
@@ -11698,7 +11719,7 @@ class HolidayEvent extends Event {
11698
11719
  return undefined;
11699
11720
  }
11700
11721
  const year = this.greg().getFullYear();
11701
- if (year < 100 || year > 2999) {
11722
+ if (year < 1752 || year > 2499) {
11702
11723
  return undefined;
11703
11724
  }
11704
11725
  const url = `https://www.hebcal.com/holidays/${urlFriendly(this.basename())}-${this.urlDateSuffix()}`;
@@ -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
  'שֶׁבְּחֶֽסֶד',
@@ -14097,9 +14115,13 @@ class OmerEvent extends Event {
14097
14115
  }
14098
14116
  return str;
14099
14117
  }
14118
+ /**
14119
+ * Returns a `https://www.hebcal.com/omer/...` URL, or `undefined` for Hebrew
14120
+ * years outside `[5513, 6260]` (roughly Gregorian 1752–2499).
14121
+ */
14100
14122
  url() {
14101
14123
  const year = this.getDate().getFullYear();
14102
- if (year < 5000 || year > 6759) {
14124
+ if (year < 5513 || year > 6260) {
14103
14125
  return undefined;
14104
14126
  }
14105
14127
  return `https://www.hebcal.com/omer/${year}/${this.omer}`;
@@ -14275,6 +14297,97 @@ function tachanunYear(year, il) {
14275
14297
  };
14276
14298
  }
14277
14299
 
14300
+ const NONE = 0;
14301
+ const HALF = 1;
14302
+ const WHOLE = 2;
14303
+ /**
14304
+ * Determines which form of Hallel (if any) is recited
14305
+ * on a given Hebrew date.
14306
+ *
14307
+ * Returns 0 (none), 1 (half Hallel), or 2 (whole Hallel).
14308
+ *
14309
+ * Whole Hallel is said on Chanukah, the first Yom Tov of Pesach, Shavuot, Sukkot,
14310
+ * Shmini Atzeret, Simchat Torah, Yom Ha'atzmaut, and Yom Yerushalayim.
14311
+ *
14312
+ * Half Hallel is said on Rosh Chodesh (not Rosh Hashanah), and the last 6 days of Pesach.
14313
+ * Rosh Chodesh Tevet falls during Chanukah, so whole Hallel is said then.
14314
+ *
14315
+ * The result is computed directly from the Hebrew month and day,
14316
+ * without generating holiday events.
14317
+ * @example
14318
+ * import {hallel, HDate, months} from '@hebcal/core';
14319
+ * hallel(new HDate(25, months.KISLEV, 5784), false); // 2 (Chanukah)
14320
+ * hallel(new HDate(1, months.SHVAT, 5784), false); // 1 (Rosh Chodesh)
14321
+ * hallel(new HDate(2, months.SHVAT, 5784), false); // 0
14322
+ * hallel(new HDate(16, months.NISAN, 5784), false); // 2 (Pesach II, Diaspora)
14323
+ * hallel(new HDate(16, months.NISAN, 5784), true); // 1 (Chol HaMoed, Israel)
14324
+ * @param hdate Hebrew date to test
14325
+ * @param il use the Israeli holiday schedule
14326
+ * @returns 0 for no Hallel, 1 for half Hallel, 2 for whole Hallel
14327
+ */
14328
+ function hallel(hdate, il) {
14329
+ const mm = hdate.getMonth();
14330
+ const dd = hdate.getDate();
14331
+ switch (mm) {
14332
+ case months.TISHREI:
14333
+ // Sukkot (15-21), Shmini Atzeret (22), Simchat Torah (23, Diaspora)
14334
+ if (dd >= 15 && dd <= (il ? 22 : 23)) {
14335
+ return WHOLE;
14336
+ }
14337
+ break;
14338
+ case months.KISLEV:
14339
+ // Chanukah begins 25 Kislev; the first candle on the evening of
14340
+ // 24 Kislev precedes the first morning of Chanukah
14341
+ if (dd >= 25) {
14342
+ return WHOLE;
14343
+ }
14344
+ break;
14345
+ case months.TEVET: {
14346
+ // Chanukah lasts 8 days, ending on 2 Tevet (3 Tevet if Kislev is short)
14347
+ const lastDay = HDate.shortKislev(hdate.getFullYear()) ? 3 : 2;
14348
+ if (dd <= lastDay) {
14349
+ return WHOLE;
14350
+ }
14351
+ break;
14352
+ }
14353
+ case months.NISAN:
14354
+ // First day(s) of Pesach
14355
+ if (dd === 15 || (dd === 16 && !il)) {
14356
+ return WHOLE;
14357
+ }
14358
+ // Remaining days of Pesach
14359
+ if (dd >= 16 && dd <= (il ? 21 : 22)) {
14360
+ return HALF;
14361
+ }
14362
+ break;
14363
+ case months.IYYAR: {
14364
+ const year = hdate.getFullYear();
14365
+ // Yom Yerushalayim
14366
+ if (dd === 28 && year >= 5727) {
14367
+ return WHOLE;
14368
+ }
14369
+ // Yom Ha'atzmaut, the day after Yom HaZikaron
14370
+ const yomHaZikaron = dateYomHaZikaron(year);
14371
+ if (yomHaZikaron !== null && dd === yomHaZikaron.getDate() + 1) {
14372
+ return WHOLE;
14373
+ }
14374
+ break;
14375
+ }
14376
+ case months.SIVAN:
14377
+ // Shavuot
14378
+ if (dd === 6 || (dd === 7 && !il)) {
14379
+ return WHOLE;
14380
+ }
14381
+ break;
14382
+ }
14383
+ // Rosh Chodesh: the 30th of any month, or the 1st of any month
14384
+ // other than Tishrei (Rosh Hashana)
14385
+ if (dd === 30 || (dd === 1 && mm !== months.TISHREI)) {
14386
+ return HALF;
14387
+ }
14388
+ return NONE;
14389
+ }
14390
+
14278
14391
  /** @internal */
14279
14392
  function renderParshaName(parsha, locale) {
14280
14393
  let name = Locale.gettext(parsha[0], locale);
@@ -14332,7 +14445,7 @@ class ParshaEvent extends Event {
14332
14445
  }
14333
14446
  url() {
14334
14447
  const year = this.greg().getFullYear();
14335
- if (year < 100 || year > 2999) {
14448
+ if (year < 1752 || year > 2499) {
14336
14449
  return undefined;
14337
14450
  }
14338
14451
  const dt = this.urlDateSuffix();
@@ -15388,40 +15501,6 @@ function makeBiurChametzEvent(hd, options) {
15388
15501
  return biurChametzEv;
15389
15502
  }
15390
15503
 
15391
- const NONE = 0;
15392
- const HALF = 1;
15393
- const WHOLE = 2;
15394
- /** @internal */
15395
- function hallel_(events, hdate) {
15396
- const abs = hdate.abs();
15397
- for (const ev of events) {
15398
- const hd = ev.getDate();
15399
- if (hd.abs() !== abs) {
15400
- continue;
15401
- }
15402
- const desc = ev.getDesc();
15403
- const month = hd.getMonth();
15404
- const mday = hd.getDate();
15405
- if (desc.startsWith('Chanukah') ||
15406
- desc.startsWith('Shavuot') ||
15407
- desc.startsWith('Sukkot') ||
15408
- (month === months.NISAN &&
15409
- (mday === 15 || mday === 16) &&
15410
- ev.hasFlag('CHAG')) || // Pesach
15411
- desc === holidayDesc.YOM_HAATZMA_UT ||
15412
- desc === holidayDesc.YOM_YERUSHALAYIM) {
15413
- return WHOLE;
15414
- }
15415
- if (ev.hasFlag('ROSH_CHODESH') ||
15416
- (desc.startsWith('Pesach') &&
15417
- desc !== holidayDesc.PESACH_I &&
15418
- desc !== holidayDesc.PESACH_II)) {
15419
- return HALF;
15420
- }
15421
- }
15422
- return NONE;
15423
- }
15424
-
15425
15504
  /*
15426
15505
  Hebcal - A Jewish Calendar Generator
15427
15506
  Copyright (c) 1994-2020 Danny Sadinoff
@@ -15682,15 +15761,9 @@ class HebrewCalendar {
15682
15761
  return getSedra(hyear, il);
15683
15762
  }
15684
15763
  /**
15685
- * Determines which form of Hallel (if any) is recited
15686
- * on a given Hebrew date.
15687
- *
15688
- * Returns 0 (none), 1 (half Hallel), or 2 (whole Hallel).
15689
- *
15690
- * Whole Hallel is said on Chanukah, the first Yom Tov of Pesach, Shavuot, Sukkot,
15691
- * Yom Ha'atzmaut, and Yom Yerushalayim.
15692
- *
15693
- * Half Hallel is said on Rosh Chodesh (not Rosh Hashanah), and the last 6 days of Pesach.
15764
+ * Determines which form of Hallel (if any) is recited on a given Hebrew date:
15765
+ * 0 (none), 1 (half Hallel), or 2 (whole Hallel).
15766
+ * See {@link hallel} for details.
15694
15767
  * @example
15695
15768
  * import {HebrewCalendar, HDate, months} from '@hebcal/core';
15696
15769
  * HebrewCalendar.hallel(new HDate(25, months.KISLEV, 5784), false); // 2 (Chanukah)
@@ -15701,11 +15774,7 @@ class HebrewCalendar {
15701
15774
  * @returns 0 for no Hallel, 1 for half Hallel, 2 for whole Hallel
15702
15775
  */
15703
15776
  static hallel(hdate, il) {
15704
- const events = getHolidaysOnDate(hdate, il);
15705
- if (!events) {
15706
- return 0;
15707
- }
15708
- return hallel_(events, hdate);
15777
+ return hallel(hdate, il);
15709
15778
  }
15710
15779
  /**
15711
15780
  * Return details on what Tachanun (or Tzidchatcha on Shabbat) is said on `hdate`.
@@ -15784,6 +15853,7 @@ exports.getHolidaysOnDate = getHolidaysOnDate;
15784
15853
  exports.getMoladAsDate = getMoladAsDate;
15785
15854
  exports.getSedra = getSedra;
15786
15855
  exports.greg = greg;
15856
+ exports.hallel = hallel;
15787
15857
  exports.holidayDesc = holidayDesc;
15788
15858
  exports.isAssurBemlacha = isAssurBemlacha;
15789
15859
  exports.isAveilut = isAveilut;