@hebcal/core 5.7.5 → 5.7.6

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/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! @hebcal/core v5.7.5 */
1
+ /*! @hebcal/core v5.7.6 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
5
5
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
6
- const version = '5.7.5';
6
+ const version = '5.7.6';
7
7
 
8
8
  /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
9
9
  /** @private */
@@ -101,7 +101,18 @@ function greg2abs(date) {
101
101
  * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
102
102
  * Clamen, Software--Practice and Experience, Volume 23, Number 4
103
103
  * (April, 1993), pages 383-404 for an explanation.
104
+ *
105
+ * Note that this function returns the daytime portion of the date.
106
+ * For example, the 15th of Cheshvan 5769 began at sundown on
107
+ * 12 November 2008 and continues through 13 November 2008. This
108
+ * function would return only the date 13 November 2008.
104
109
  * @param abs - R.D. number of days
110
+ * @example
111
+ * const abs = hebrew2abs(5769, months.CHESHVAN, 15);
112
+ * const date = abs2greg(abs); // 13 November 2008
113
+ * const year = date.getFullYear(); // 2008
114
+ * const monthNum = date.getMonth() + 1; // 11
115
+ * const day = date.getDate(); // 13
105
116
  */
106
117
  function abs2greg(abs) {
107
118
  if (typeof abs !== 'number') {
@@ -212,6 +223,8 @@ function assertNumber(n, name) {
212
223
  * @param year Hebrew year
213
224
  * @param month Hebrew month
214
225
  * @param day Hebrew date (1-30)
226
+ * @example
227
+ * const abs = hebrew2abs(5769, months.CHESHVAN, 15);
215
228
  */
216
229
  function hebrew2abs(year, month, day) {
217
230
  assertNumber(year, 'year');
@@ -1430,13 +1443,20 @@ class HDate {
1430
1443
  }
1431
1444
  /**
1432
1445
  * Converts this Hebrew date to the corresponding Gregorian date.
1446
+ *
1447
+ * The returned `Date` object will be in the local (i.e. host system) time zone.
1448
+ * Hours, minutes, seconds and milliseconds will all be zero.
1449
+ *
1433
1450
  * Note that this function returns the daytime portion of the date.
1434
1451
  * For example, the 15th of Cheshvan 5769 began at sundown on
1435
1452
  * 12 November 2008 and continues through 13 November 2008. This
1436
1453
  * function would return only the date 13 November 2008.
1437
1454
  * @example
1438
1455
  * const hd = new HDate(15, 'Cheshvan', 5769);
1439
- * hd.greg(); // 13 November 2008
1456
+ * const date = hd.greg(); // 13 November 2008
1457
+ * const year = date.getFullYear(); // 2008
1458
+ * const monthNum = date.getMonth() + 1; // 11
1459
+ * const day = date.getDate(); // 13
1440
1460
  */
1441
1461
  greg() {
1442
1462
  return abs2greg(this.abs());
@@ -2292,10 +2312,6 @@ class HebrewDateEvent extends Event {
2292
2312
 
2293
2313
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2294
2314
 
2295
- function getDefaultExportFromCjs (x) {
2296
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2297
- }
2298
-
2299
2315
  var es_array_includes = {};
2300
2316
 
2301
2317
  var globalThis_1;
@@ -11646,111 +11662,250 @@ function renderParshaName(parsha, locale) {
11646
11662
  return str.normalize();
11647
11663
  }
11648
11664
 
11649
- var quickLru;
11650
- var hasRequiredQuickLru;
11651
- function requireQuickLru() {
11652
- if (hasRequiredQuickLru) return quickLru;
11653
- hasRequiredQuickLru = 1;
11654
- class QuickLRU {
11655
- constructor() {
11656
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11657
- if (!(options.maxSize && options.maxSize > 0)) {
11658
- throw new TypeError('`maxSize` must be a number greater than 0');
11665
+ class QuickLRU extends Map {
11666
+ constructor() {
11667
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11668
+ super();
11669
+ if (!(options.maxSize && options.maxSize > 0)) {
11670
+ throw new TypeError('`maxSize` must be a number greater than 0');
11671
+ }
11672
+ if (typeof options.maxAge === 'number' && options.maxAge === 0) {
11673
+ throw new TypeError('`maxAge` must be a number greater than 0');
11674
+ }
11675
+
11676
+ // TODO: Use private class fields when ESLint supports them.
11677
+ this.maxSize = options.maxSize;
11678
+ this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
11679
+ this.onEviction = options.onEviction;
11680
+ this.cache = new Map();
11681
+ this.oldCache = new Map();
11682
+ this._size = 0;
11683
+ }
11684
+
11685
+ // TODO: Use private class methods when targeting Node.js 16.
11686
+ _emitEvictions(cache) {
11687
+ if (typeof this.onEviction !== 'function') {
11688
+ return;
11689
+ }
11690
+ for (const [key, item] of cache) {
11691
+ this.onEviction(key, item.value);
11692
+ }
11693
+ }
11694
+ _deleteIfExpired(key, item) {
11695
+ if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
11696
+ if (typeof this.onEviction === 'function') {
11697
+ this.onEviction(key, item.value);
11659
11698
  }
11660
- this.maxSize = options.maxSize;
11661
- this.cache = new Map();
11662
- this.oldCache = new Map();
11699
+ return this.delete(key);
11700
+ }
11701
+ return false;
11702
+ }
11703
+ _getOrDeleteIfExpired(key, item) {
11704
+ const deleted = this._deleteIfExpired(key, item);
11705
+ if (deleted === false) {
11706
+ return item.value;
11707
+ }
11708
+ }
11709
+ _getItemValue(key, item) {
11710
+ return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
11711
+ }
11712
+ _peek(key, cache) {
11713
+ const item = cache.get(key);
11714
+ return this._getItemValue(key, item);
11715
+ }
11716
+ _set(key, value) {
11717
+ this.cache.set(key, value);
11718
+ this._size++;
11719
+ if (this._size >= this.maxSize) {
11663
11720
  this._size = 0;
11721
+ this._emitEvictions(this.oldCache);
11722
+ this.oldCache = this.cache;
11723
+ this.cache = new Map();
11664
11724
  }
11665
- _set(key, value) {
11666
- this.cache.set(key, value);
11667
- this._size++;
11668
- if (this._size >= this.maxSize) {
11669
- this._size = 0;
11670
- this.oldCache = this.cache;
11671
- this.cache = new Map();
11725
+ }
11726
+ _moveToRecent(key, item) {
11727
+ this.oldCache.delete(key);
11728
+ this._set(key, item);
11729
+ }
11730
+ *_entriesAscending() {
11731
+ for (const item of this.oldCache) {
11732
+ const [key, value] = item;
11733
+ if (!this.cache.has(key)) {
11734
+ const deleted = this._deleteIfExpired(key, value);
11735
+ if (deleted === false) {
11736
+ yield item;
11737
+ }
11672
11738
  }
11673
11739
  }
11674
- get(key) {
11675
- if (this.cache.has(key)) {
11676
- return this.cache.get(key);
11677
- }
11678
- if (this.oldCache.has(key)) {
11679
- const value = this.oldCache.get(key);
11680
- this.oldCache.delete(key);
11681
- this._set(key, value);
11682
- return value;
11740
+ for (const item of this.cache) {
11741
+ const [key, value] = item;
11742
+ const deleted = this._deleteIfExpired(key, value);
11743
+ if (deleted === false) {
11744
+ yield item;
11683
11745
  }
11684
11746
  }
11685
- set(key, value) {
11686
- if (this.cache.has(key)) {
11687
- this.cache.set(key, value);
11688
- } else {
11689
- this._set(key, value);
11747
+ }
11748
+ get(key) {
11749
+ if (this.cache.has(key)) {
11750
+ const item = this.cache.get(key);
11751
+ return this._getItemValue(key, item);
11752
+ }
11753
+ if (this.oldCache.has(key)) {
11754
+ const item = this.oldCache.get(key);
11755
+ if (this._deleteIfExpired(key, item) === false) {
11756
+ this._moveToRecent(key, item);
11757
+ return item.value;
11690
11758
  }
11691
- return this;
11692
11759
  }
11693
- has(key) {
11694
- return this.cache.has(key) || this.oldCache.has(key);
11760
+ }
11761
+ set(key, value) {
11762
+ let {
11763
+ maxAge = this.maxAge
11764
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
11765
+ const expiry = typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY ? Date.now() + maxAge : undefined;
11766
+ if (this.cache.has(key)) {
11767
+ this.cache.set(key, {
11768
+ value,
11769
+ expiry
11770
+ });
11771
+ } else {
11772
+ this._set(key, {
11773
+ value,
11774
+ expiry
11775
+ });
11776
+ }
11777
+ return this;
11778
+ }
11779
+ has(key) {
11780
+ if (this.cache.has(key)) {
11781
+ return !this._deleteIfExpired(key, this.cache.get(key));
11695
11782
  }
11696
- peek(key) {
11697
- if (this.cache.has(key)) {
11698
- return this.cache.get(key);
11699
- }
11700
- if (this.oldCache.has(key)) {
11701
- return this.oldCache.get(key);
11702
- }
11783
+ if (this.oldCache.has(key)) {
11784
+ return !this._deleteIfExpired(key, this.oldCache.get(key));
11703
11785
  }
11704
- delete(key) {
11705
- const deleted = this.cache.delete(key);
11706
- if (deleted) {
11707
- this._size--;
11708
- }
11709
- return this.oldCache.delete(key) || deleted;
11786
+ return false;
11787
+ }
11788
+ peek(key) {
11789
+ if (this.cache.has(key)) {
11790
+ return this._peek(key, this.cache);
11791
+ }
11792
+ if (this.oldCache.has(key)) {
11793
+ return this._peek(key, this.oldCache);
11794
+ }
11795
+ }
11796
+ delete(key) {
11797
+ const deleted = this.cache.delete(key);
11798
+ if (deleted) {
11799
+ this._size--;
11710
11800
  }
11711
- clear() {
11712
- this.cache.clear();
11713
- this.oldCache.clear();
11801
+ return this.oldCache.delete(key) || deleted;
11802
+ }
11803
+ clear() {
11804
+ this.cache.clear();
11805
+ this.oldCache.clear();
11806
+ this._size = 0;
11807
+ }
11808
+ resize(newSize) {
11809
+ if (!(newSize && newSize > 0)) {
11810
+ throw new TypeError('`maxSize` must be a number greater than 0');
11811
+ }
11812
+ const items = [...this._entriesAscending()];
11813
+ const removeCount = items.length - newSize;
11814
+ if (removeCount < 0) {
11815
+ this.cache = new Map(items);
11816
+ this.oldCache = new Map();
11817
+ this._size = items.length;
11818
+ } else {
11819
+ if (removeCount > 0) {
11820
+ this._emitEvictions(items.slice(0, removeCount));
11821
+ }
11822
+ this.oldCache = new Map(items.slice(removeCount));
11823
+ this.cache = new Map();
11714
11824
  this._size = 0;
11715
11825
  }
11716
- *keys() {
11717
- for (const [key] of this) {
11718
- yield key;
11826
+ this.maxSize = newSize;
11827
+ }
11828
+ *keys() {
11829
+ for (const [key] of this) {
11830
+ yield key;
11831
+ }
11832
+ }
11833
+ *values() {
11834
+ for (const [, value] of this) {
11835
+ yield value;
11836
+ }
11837
+ }
11838
+ *[Symbol.iterator]() {
11839
+ for (const item of this.cache) {
11840
+ const [key, value] = item;
11841
+ const deleted = this._deleteIfExpired(key, value);
11842
+ if (deleted === false) {
11843
+ yield [key, value.value];
11719
11844
  }
11720
11845
  }
11721
- *values() {
11722
- for (const [, value] of this) {
11723
- yield value;
11846
+ for (const item of this.oldCache) {
11847
+ const [key, value] = item;
11848
+ if (!this.cache.has(key)) {
11849
+ const deleted = this._deleteIfExpired(key, value);
11850
+ if (deleted === false) {
11851
+ yield [key, value.value];
11852
+ }
11724
11853
  }
11725
11854
  }
11726
- *[Symbol.iterator]() {
11727
- for (const item of this.cache) {
11728
- yield item;
11855
+ }
11856
+ *entriesDescending() {
11857
+ let items = [...this.cache];
11858
+ for (let i = items.length - 1; i >= 0; --i) {
11859
+ const item = items[i];
11860
+ const [key, value] = item;
11861
+ const deleted = this._deleteIfExpired(key, value);
11862
+ if (deleted === false) {
11863
+ yield [key, value.value];
11729
11864
  }
11730
- for (const item of this.oldCache) {
11731
- const [key] = item;
11732
- if (!this.cache.has(key)) {
11733
- yield item;
11865
+ }
11866
+ items = [...this.oldCache];
11867
+ for (let i = items.length - 1; i >= 0; --i) {
11868
+ const item = items[i];
11869
+ const [key, value] = item;
11870
+ if (!this.cache.has(key)) {
11871
+ const deleted = this._deleteIfExpired(key, value);
11872
+ if (deleted === false) {
11873
+ yield [key, value.value];
11734
11874
  }
11735
11875
  }
11736
11876
  }
11737
- get size() {
11738
- let oldCacheSize = 0;
11739
- for (const key of this.oldCache.keys()) {
11740
- if (!this.cache.has(key)) {
11741
- oldCacheSize++;
11742
- }
11877
+ }
11878
+ *entriesAscending() {
11879
+ for (const [key, value] of this._entriesAscending()) {
11880
+ yield [key, value.value];
11881
+ }
11882
+ }
11883
+ get size() {
11884
+ if (!this._size) {
11885
+ return this.oldCache.size;
11886
+ }
11887
+ let oldCacheSize = 0;
11888
+ for (const key of this.oldCache.keys()) {
11889
+ if (!this.cache.has(key)) {
11890
+ oldCacheSize++;
11743
11891
  }
11744
- return this._size + oldCacheSize;
11745
11892
  }
11893
+ return Math.min(this._size + oldCacheSize, this.maxSize);
11894
+ }
11895
+ entries() {
11896
+ return this.entriesAscending();
11897
+ }
11898
+ forEach(callbackFunction) {
11899
+ let thisArgument = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
11900
+ for (const [key, value] of this.entriesAscending()) {
11901
+ callbackFunction.call(thisArgument, value, key, this);
11902
+ }
11903
+ }
11904
+ get [Symbol.toStringTag]() {
11905
+ return JSON.stringify([...this.entriesAscending()]);
11746
11906
  }
11747
- quickLru = QuickLRU;
11748
- return quickLru;
11749
11907
  }
11750
11908
 
11751
- var quickLruExports = requireQuickLru();
11752
- var QuickLRU = /*@__PURE__*/getDefaultExportFromCjs(quickLruExports);
11753
-
11754
11909
  /*
11755
11910
  Hebcal - A Jewish Calendar Generator
11756
11911
  Copyright (c) 1994-2020 Danny Sadinoff