@hebcal/core 5.7.5 → 5.7.7

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,10 +1,11 @@
1
- /*! @hebcal/core v5.7.5 */
1
+ /*! @hebcal/core v5.7.7 */
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.7';
7
7
 
8
+ /*! @hebcal/hdate v0.12.0 */
8
9
  /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
9
10
  /** @private */
10
11
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@@ -101,7 +102,18 @@ function greg2abs(date) {
101
102
  * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
102
103
  * Clamen, Software--Practice and Experience, Volume 23, Number 4
103
104
  * (April, 1993), pages 383-404 for an explanation.
105
+ *
106
+ * Note that this function returns the daytime portion of the date.
107
+ * For example, the 15th of Cheshvan 5769 began at sundown on
108
+ * 12 November 2008 and continues through 13 November 2008. This
109
+ * function would return only the date 13 November 2008.
104
110
  * @param abs - R.D. number of days
111
+ * @example
112
+ * const abs = hebrew2abs(5769, months.CHESHVAN, 15);
113
+ * const date = abs2greg(abs); // 13 November 2008
114
+ * const year = date.getFullYear(); // 2008
115
+ * const monthNum = date.getMonth() + 1; // 11
116
+ * const day = date.getDate(); // 13
105
117
  */
106
118
  function abs2greg(abs) {
107
119
  if (typeof abs !== 'number') {
@@ -125,6 +137,8 @@ function abs2greg(abs) {
125
137
  return dt;
126
138
  }
127
139
 
140
+ /*! @hebcal/hdate v0.12.0 */
141
+
128
142
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
129
143
  /**
130
144
  * Gregorian date helper functions
@@ -137,6 +151,7 @@ exports.greg.greg2abs = greg2abs;
137
151
  exports.greg.isDate = isDate;
138
152
  exports.greg.isLeapYear = isGregLeapYear;
139
153
 
154
+ /*! @hebcal/hdate v0.12.0 */
140
155
  /*
141
156
  * More minimal HDate
142
157
  */
@@ -212,6 +227,8 @@ function assertNumber(n, name) {
212
227
  * @param year Hebrew year
213
228
  * @param month Hebrew month
214
229
  * @param day Hebrew date (1-30)
230
+ * @example
231
+ * const abs = hebrew2abs(5769, months.CHESHVAN, 15);
215
232
  */
216
233
  function hebrew2abs(year, month, day) {
217
234
  assertNumber(year, 'year');
@@ -461,6 +478,7 @@ function monthFromName(monthName) {
461
478
  return ADAR_I$2;
462
479
  }
463
480
  return ADAR_II$2;
481
+ // else assume sheini
464
482
  }
465
483
  break;
466
484
  case 'ס':
@@ -497,6 +515,7 @@ function monthFromName(monthName) {
497
515
  throw new RangeError(`Unable to parse month name: ${monthName}`);
498
516
  }
499
517
 
518
+ /*! @hebcal/hdate v0.12.0 */
500
519
  const NISAN$3 = months.NISAN;
501
520
  const CHESHVAN = months.CHESHVAN;
502
521
  const KISLEV$1 = months.KISLEV;
@@ -591,6 +610,7 @@ function getBirthdayHD(hyear, date) {
591
610
  };
592
611
  }
593
612
 
613
+ /*! @hebcal/hdate v0.12.0 */
594
614
  const GERESH = '׳';
595
615
  const GERSHAYIM = '״';
596
616
  const alefbet = {
@@ -706,6 +726,7 @@ function gematriyaStrToNum(str) {
706
726
  return num;
707
727
  }
708
728
 
729
+ /*! @hebcal/hdate v0.12.0 */
709
730
  const sefirot = {
710
731
  en: {
711
732
  infix: 'within ',
@@ -880,6 +901,8 @@ function omerEmoji(omerDay) {
880
901
  return String.fromCodePoint(codePoint);
881
902
  }
882
903
 
904
+ /*! @hebcal/hdate v0.12.0 */
905
+
883
906
  /**
884
907
  * Calculates the molad for a Hebrew month
885
908
  */
@@ -910,6 +933,7 @@ function molad(year, month) {
910
933
  };
911
934
  }
912
935
 
936
+ /*! @hebcal/hdate v0.12.0 */
913
937
  /**
914
938
  * Formats a number with leading zeros so the resulting string is 4 digits long.
915
939
  * Similar to `string.padStart(4, '0')` but will also format
@@ -939,6 +963,7 @@ function pad2(num) {
939
963
  return String(num);
940
964
  }
941
965
 
966
+ /*! @hebcal/hdate v0.12.0 */
942
967
  const _formatters = new Map();
943
968
  /**
944
969
  * @private
@@ -994,6 +1019,7 @@ function isoDateString(dt) {
994
1019
  return pad4(dt.getFullYear()) + '-' + pad2(dt.getMonth() + 1) + '-' + pad2(dt.getDate());
995
1020
  }
996
1021
 
1022
+ /*! @hebcal/hdate v0.12.0 */
997
1023
  var poAshkenazi$1 = {
998
1024
  "headers": {
999
1025
  "plural-forms": "nplurals=2; plural=(n > 1);"
@@ -1005,6 +1031,7 @@ var poAshkenazi$1 = {
1005
1031
  }
1006
1032
  };
1007
1033
 
1034
+ /*! @hebcal/hdate v0.12.0 */
1008
1035
  var poHe$1 = {
1009
1036
  "headers": {
1010
1037
  "plural-forms": "nplurals=2; plural=(n > 1);"
@@ -1029,6 +1056,7 @@ var poHe$1 = {
1029
1056
  }
1030
1057
  };
1031
1058
 
1059
+ /*! @hebcal/hdate v0.12.0 */
1032
1060
  const noopLocale = {
1033
1061
  headers: {
1034
1062
  'plural-forms': 'nplurals=2; plural=(n!=1);'
@@ -1237,6 +1265,8 @@ const poHeNoNikud$1 = {
1237
1265
  };
1238
1266
  Locale.addLocale('he-x-NoNikud', poHeNoNikud$1);
1239
1267
 
1268
+ /*! @hebcal/hdate v0.12.0 */
1269
+
1240
1270
  /*
1241
1271
  Hebcal - A Jewish Calendar Generator
1242
1272
  Copyright (c) 1994-2020 Danny Sadinoff
@@ -1430,13 +1460,20 @@ class HDate {
1430
1460
  }
1431
1461
  /**
1432
1462
  * Converts this Hebrew date to the corresponding Gregorian date.
1463
+ *
1464
+ * The returned `Date` object will be in the local (i.e. host system) time zone.
1465
+ * Hours, minutes, seconds and milliseconds will all be zero.
1466
+ *
1433
1467
  * Note that this function returns the daytime portion of the date.
1434
1468
  * For example, the 15th of Cheshvan 5769 began at sundown on
1435
1469
  * 12 November 2008 and continues through 13 November 2008. This
1436
1470
  * function would return only the date 13 November 2008.
1437
1471
  * @example
1438
1472
  * const hd = new HDate(15, 'Cheshvan', 5769);
1439
- * hd.greg(); // 13 November 2008
1473
+ * const date = hd.greg(); // 13 November 2008
1474
+ * const year = date.getFullYear(); // 2008
1475
+ * const monthNum = date.getMonth() + 1; // 11
1476
+ * const day = date.getDate(); // 13
1440
1477
  */
1441
1478
  greg() {
1442
1479
  return abs2greg(this.abs());
@@ -2292,10 +2329,6 @@ class HebrewDateEvent extends Event {
2292
2329
 
2293
2330
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2294
2331
 
2295
- function getDefaultExportFromCjs (x) {
2296
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2297
- }
2298
-
2299
2332
  var es_array_includes = {};
2300
2333
 
2301
2334
  var globalThis_1;
@@ -11646,111 +11679,250 @@ function renderParshaName(parsha, locale) {
11646
11679
  return str.normalize();
11647
11680
  }
11648
11681
 
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');
11682
+ class QuickLRU extends Map {
11683
+ constructor() {
11684
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11685
+ super();
11686
+ if (!(options.maxSize && options.maxSize > 0)) {
11687
+ throw new TypeError('`maxSize` must be a number greater than 0');
11688
+ }
11689
+ if (typeof options.maxAge === 'number' && options.maxAge === 0) {
11690
+ throw new TypeError('`maxAge` must be a number greater than 0');
11691
+ }
11692
+
11693
+ // TODO: Use private class fields when ESLint supports them.
11694
+ this.maxSize = options.maxSize;
11695
+ this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
11696
+ this.onEviction = options.onEviction;
11697
+ this.cache = new Map();
11698
+ this.oldCache = new Map();
11699
+ this._size = 0;
11700
+ }
11701
+
11702
+ // TODO: Use private class methods when targeting Node.js 16.
11703
+ _emitEvictions(cache) {
11704
+ if (typeof this.onEviction !== 'function') {
11705
+ return;
11706
+ }
11707
+ for (const [key, item] of cache) {
11708
+ this.onEviction(key, item.value);
11709
+ }
11710
+ }
11711
+ _deleteIfExpired(key, item) {
11712
+ if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
11713
+ if (typeof this.onEviction === 'function') {
11714
+ this.onEviction(key, item.value);
11659
11715
  }
11660
- this.maxSize = options.maxSize;
11661
- this.cache = new Map();
11662
- this.oldCache = new Map();
11716
+ return this.delete(key);
11717
+ }
11718
+ return false;
11719
+ }
11720
+ _getOrDeleteIfExpired(key, item) {
11721
+ const deleted = this._deleteIfExpired(key, item);
11722
+ if (deleted === false) {
11723
+ return item.value;
11724
+ }
11725
+ }
11726
+ _getItemValue(key, item) {
11727
+ return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
11728
+ }
11729
+ _peek(key, cache) {
11730
+ const item = cache.get(key);
11731
+ return this._getItemValue(key, item);
11732
+ }
11733
+ _set(key, value) {
11734
+ this.cache.set(key, value);
11735
+ this._size++;
11736
+ if (this._size >= this.maxSize) {
11663
11737
  this._size = 0;
11738
+ this._emitEvictions(this.oldCache);
11739
+ this.oldCache = this.cache;
11740
+ this.cache = new Map();
11664
11741
  }
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();
11742
+ }
11743
+ _moveToRecent(key, item) {
11744
+ this.oldCache.delete(key);
11745
+ this._set(key, item);
11746
+ }
11747
+ *_entriesAscending() {
11748
+ for (const item of this.oldCache) {
11749
+ const [key, value] = item;
11750
+ if (!this.cache.has(key)) {
11751
+ const deleted = this._deleteIfExpired(key, value);
11752
+ if (deleted === false) {
11753
+ yield item;
11754
+ }
11672
11755
  }
11673
11756
  }
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;
11757
+ for (const item of this.cache) {
11758
+ const [key, value] = item;
11759
+ const deleted = this._deleteIfExpired(key, value);
11760
+ if (deleted === false) {
11761
+ yield item;
11683
11762
  }
11684
11763
  }
11685
- set(key, value) {
11686
- if (this.cache.has(key)) {
11687
- this.cache.set(key, value);
11688
- } else {
11689
- this._set(key, value);
11764
+ }
11765
+ get(key) {
11766
+ if (this.cache.has(key)) {
11767
+ const item = this.cache.get(key);
11768
+ return this._getItemValue(key, item);
11769
+ }
11770
+ if (this.oldCache.has(key)) {
11771
+ const item = this.oldCache.get(key);
11772
+ if (this._deleteIfExpired(key, item) === false) {
11773
+ this._moveToRecent(key, item);
11774
+ return item.value;
11690
11775
  }
11691
- return this;
11692
11776
  }
11693
- has(key) {
11694
- return this.cache.has(key) || this.oldCache.has(key);
11777
+ }
11778
+ set(key, value) {
11779
+ let {
11780
+ maxAge = this.maxAge
11781
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
11782
+ const expiry = typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY ? Date.now() + maxAge : undefined;
11783
+ if (this.cache.has(key)) {
11784
+ this.cache.set(key, {
11785
+ value,
11786
+ expiry
11787
+ });
11788
+ } else {
11789
+ this._set(key, {
11790
+ value,
11791
+ expiry
11792
+ });
11793
+ }
11794
+ return this;
11795
+ }
11796
+ has(key) {
11797
+ if (this.cache.has(key)) {
11798
+ return !this._deleteIfExpired(key, this.cache.get(key));
11799
+ }
11800
+ if (this.oldCache.has(key)) {
11801
+ return !this._deleteIfExpired(key, this.oldCache.get(key));
11695
11802
  }
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
- }
11803
+ return false;
11804
+ }
11805
+ peek(key) {
11806
+ if (this.cache.has(key)) {
11807
+ return this._peek(key, this.cache);
11703
11808
  }
11704
- delete(key) {
11705
- const deleted = this.cache.delete(key);
11706
- if (deleted) {
11707
- this._size--;
11708
- }
11709
- return this.oldCache.delete(key) || deleted;
11809
+ if (this.oldCache.has(key)) {
11810
+ return this._peek(key, this.oldCache);
11710
11811
  }
11711
- clear() {
11712
- this.cache.clear();
11713
- this.oldCache.clear();
11812
+ }
11813
+ delete(key) {
11814
+ const deleted = this.cache.delete(key);
11815
+ if (deleted) {
11816
+ this._size--;
11817
+ }
11818
+ return this.oldCache.delete(key) || deleted;
11819
+ }
11820
+ clear() {
11821
+ this.cache.clear();
11822
+ this.oldCache.clear();
11823
+ this._size = 0;
11824
+ }
11825
+ resize(newSize) {
11826
+ if (!(newSize && newSize > 0)) {
11827
+ throw new TypeError('`maxSize` must be a number greater than 0');
11828
+ }
11829
+ const items = [...this._entriesAscending()];
11830
+ const removeCount = items.length - newSize;
11831
+ if (removeCount < 0) {
11832
+ this.cache = new Map(items);
11833
+ this.oldCache = new Map();
11834
+ this._size = items.length;
11835
+ } else {
11836
+ if (removeCount > 0) {
11837
+ this._emitEvictions(items.slice(0, removeCount));
11838
+ }
11839
+ this.oldCache = new Map(items.slice(removeCount));
11840
+ this.cache = new Map();
11714
11841
  this._size = 0;
11715
11842
  }
11716
- *keys() {
11717
- for (const [key] of this) {
11718
- yield key;
11843
+ this.maxSize = newSize;
11844
+ }
11845
+ *keys() {
11846
+ for (const [key] of this) {
11847
+ yield key;
11848
+ }
11849
+ }
11850
+ *values() {
11851
+ for (const [, value] of this) {
11852
+ yield value;
11853
+ }
11854
+ }
11855
+ *[Symbol.iterator]() {
11856
+ for (const item of this.cache) {
11857
+ const [key, value] = item;
11858
+ const deleted = this._deleteIfExpired(key, value);
11859
+ if (deleted === false) {
11860
+ yield [key, value.value];
11719
11861
  }
11720
11862
  }
11721
- *values() {
11722
- for (const [, value] of this) {
11723
- yield value;
11863
+ for (const item of this.oldCache) {
11864
+ const [key, value] = item;
11865
+ if (!this.cache.has(key)) {
11866
+ const deleted = this._deleteIfExpired(key, value);
11867
+ if (deleted === false) {
11868
+ yield [key, value.value];
11869
+ }
11724
11870
  }
11725
11871
  }
11726
- *[Symbol.iterator]() {
11727
- for (const item of this.cache) {
11728
- yield item;
11872
+ }
11873
+ *entriesDescending() {
11874
+ let items = [...this.cache];
11875
+ for (let i = items.length - 1; i >= 0; --i) {
11876
+ const item = items[i];
11877
+ const [key, value] = item;
11878
+ const deleted = this._deleteIfExpired(key, value);
11879
+ if (deleted === false) {
11880
+ yield [key, value.value];
11729
11881
  }
11730
- for (const item of this.oldCache) {
11731
- const [key] = item;
11732
- if (!this.cache.has(key)) {
11733
- yield item;
11882
+ }
11883
+ items = [...this.oldCache];
11884
+ for (let i = items.length - 1; i >= 0; --i) {
11885
+ const item = items[i];
11886
+ const [key, value] = item;
11887
+ if (!this.cache.has(key)) {
11888
+ const deleted = this._deleteIfExpired(key, value);
11889
+ if (deleted === false) {
11890
+ yield [key, value.value];
11734
11891
  }
11735
11892
  }
11736
11893
  }
11737
- get size() {
11738
- let oldCacheSize = 0;
11739
- for (const key of this.oldCache.keys()) {
11740
- if (!this.cache.has(key)) {
11741
- oldCacheSize++;
11742
- }
11894
+ }
11895
+ *entriesAscending() {
11896
+ for (const [key, value] of this._entriesAscending()) {
11897
+ yield [key, value.value];
11898
+ }
11899
+ }
11900
+ get size() {
11901
+ if (!this._size) {
11902
+ return this.oldCache.size;
11903
+ }
11904
+ let oldCacheSize = 0;
11905
+ for (const key of this.oldCache.keys()) {
11906
+ if (!this.cache.has(key)) {
11907
+ oldCacheSize++;
11743
11908
  }
11744
- return this._size + oldCacheSize;
11745
11909
  }
11910
+ return Math.min(this._size + oldCacheSize, this.maxSize);
11911
+ }
11912
+ entries() {
11913
+ return this.entriesAscending();
11914
+ }
11915
+ forEach(callbackFunction) {
11916
+ let thisArgument = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
11917
+ for (const [key, value] of this.entriesAscending()) {
11918
+ callbackFunction.call(thisArgument, value, key, this);
11919
+ }
11920
+ }
11921
+ get [Symbol.toStringTag]() {
11922
+ return JSON.stringify([...this.entriesAscending()]);
11746
11923
  }
11747
- quickLru = QuickLRU;
11748
- return quickLru;
11749
11924
  }
11750
11925
 
11751
- var quickLruExports = requireQuickLru();
11752
- var QuickLRU = /*@__PURE__*/getDefaultExportFromCjs(quickLruExports);
11753
-
11754
11926
  /*
11755
11927
  Hebcal - A Jewish Calendar Generator
11756
11928
  Copyright (c) 1994-2020 Danny Sadinoff