@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/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v5.7.5 */
1
+ /*! @hebcal/core v5.7.7 */
2
2
  'use strict';
3
3
 
4
4
  var hdate = require('@hebcal/hdate');
@@ -6,7 +6,7 @@ var noaa = require('@hebcal/noaa');
6
6
  require('temporal-polyfill/global');
7
7
 
8
8
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
9
- const version = '5.7.5';
9
+ const version = '5.7.7';
10
10
 
11
11
  var poAshkenazi = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);" }, "contexts": { "": { "Shabbat": ["Shabbos"], "Achrei Mot": ["Achrei Mos"], "Bechukotai": ["Bechukosai"], "Beha'alotcha": ["Beha’aloscha"], "Bereshit": ["Bereshis"], "Chukat": ["Chukas"], "Erev Shavuot": ["Erev Shavuos"], "Erev Sukkot": ["Erev Sukkos"], "Ki Tavo": ["Ki Savo"], "Ki Teitzei": ["Ki Seitzei"], "Ki Tisa": ["Ki Sisa"], "Matot": ["Matos"], "Purim Katan": ["Purim Koton"], "Shabbat Chazon": ["Shabbos Chazon"], "Shabbat HaChodesh": ["Shabbos HaChodesh"], "Shabbat HaGadol": ["Shabbos HaGadol"], "Shabbat Nachamu": ["Shabbos Nachamu"], "Shabbat Parah": ["Shabbos Parah"], "Shabbat Shekalim": ["Shabbos Shekalim"], "Shabbat Shuva": ["Shabbos Shuvah"], "Shabbat Zachor": ["Shabbos Zachor"], "Shavuot": ["Shavuos"], "Shavuot I": ["Shavuos I"], "Shavuot II": ["Shavuos II"], "Shemot": ["Shemos"], "Shmini Atzeret": ["Shmini Atzeres"], "Simchat Torah": ["Simchas Torah"], "Sukkot": ["Sukkos"], "Sukkot I": ["Sukkos I"], "Sukkot II": ["Sukkos II"], "Sukkot II (CH''M)": ["Sukkos II (CH’’M)"], "Sukkot III (CH''M)": ["Sukkos III (CH’’M)"], "Sukkot IV (CH''M)": ["Sukkos IV (CH’’M)"], "Sukkot V (CH''M)": ["Sukkos V (CH’’M)"], "Sukkot VI (CH''M)": ["Sukkos VI (CH’’M)"], "Sukkot VII (Hoshana Raba)": ["Sukkos VII (Hoshana Raba)"], "Ta'anit Bechorot": ["Ta’anis Bechoros"], "Ta'anit Esther": ["Ta’anis Esther"], "Toldot": ["Toldos"], "Vaetchanan": ["Vaeschanan"], "Yitro": ["Yisro"], "Vezot Haberakhah": ["Vezos Haberakhah"], "Parashat": ["Parshas"], "Leil Selichot": ["Leil Selichos"], "Shabbat Mevarchim Chodesh": ["Shabbos Mevorchim Chodesh"], "Shabbat Shirah": ["Shabbos Shirah"], "Asara B'Tevet": ["Asara B’Teves"], "Alot HaShachar": ["Alos HaShachar"], "Kriat Shema, sof zeman": ["Krias Shema, sof zman"], "Tefilah, sof zeman": ["Tefilah, sof zman"], "Kriat Shema, sof zeman (MGA)": ["Krias Shema, sof zman (MGA)"], "Tefilah, sof zeman (MGA)": ["Tefilah, sof zman (MGA)"], "Chatzot HaLailah": ["Chatzos HaLailah"], "Chatzot hayom": ["Chatzos"], "Tzeit HaKochavim": ["Tzeis HaKochavim"], "Birkat Hachamah": ["Birkas Hachamah"], "Shushan Purim Katan": ["Shushan Purim Koton"] } } };
12
12
 
@@ -2496,136 +2496,290 @@ function renderParshaName(parsha, locale) {
2496
2496
  return str.normalize();
2497
2497
  }
2498
2498
 
2499
- function getDefaultExportFromCjs (x) {
2500
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2501
- }
2499
+ class QuickLRU extends Map {
2500
+ constructor(options = {}) {
2501
+ super();
2502
+
2503
+ if (!(options.maxSize && options.maxSize > 0)) {
2504
+ throw new TypeError('`maxSize` must be a number greater than 0');
2505
+ }
2502
2506
 
2503
- var quickLru;
2504
- var hasRequiredQuickLru;
2507
+ if (typeof options.maxAge === 'number' && options.maxAge === 0) {
2508
+ throw new TypeError('`maxAge` must be a number greater than 0');
2509
+ }
2505
2510
 
2506
- function requireQuickLru () {
2507
- if (hasRequiredQuickLru) return quickLru;
2508
- hasRequiredQuickLru = 1;
2511
+ // TODO: Use private class fields when ESLint supports them.
2512
+ this.maxSize = options.maxSize;
2513
+ this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
2514
+ this.onEviction = options.onEviction;
2515
+ this.cache = new Map();
2516
+ this.oldCache = new Map();
2517
+ this._size = 0;
2518
+ }
2509
2519
 
2510
- class QuickLRU {
2511
- constructor(options = {}) {
2512
- if (!(options.maxSize && options.maxSize > 0)) {
2513
- throw new TypeError('`maxSize` must be a number greater than 0');
2520
+ // TODO: Use private class methods when targeting Node.js 16.
2521
+ _emitEvictions(cache) {
2522
+ if (typeof this.onEviction !== 'function') {
2523
+ return;
2524
+ }
2525
+
2526
+ for (const [key, item] of cache) {
2527
+ this.onEviction(key, item.value);
2528
+ }
2529
+ }
2530
+
2531
+ _deleteIfExpired(key, item) {
2532
+ if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
2533
+ if (typeof this.onEviction === 'function') {
2534
+ this.onEviction(key, item.value);
2514
2535
  }
2515
2536
 
2516
- this.maxSize = options.maxSize;
2517
- this.cache = new Map();
2518
- this.oldCache = new Map();
2537
+ return this.delete(key);
2538
+ }
2539
+
2540
+ return false;
2541
+ }
2542
+
2543
+ _getOrDeleteIfExpired(key, item) {
2544
+ const deleted = this._deleteIfExpired(key, item);
2545
+ if (deleted === false) {
2546
+ return item.value;
2547
+ }
2548
+ }
2549
+
2550
+ _getItemValue(key, item) {
2551
+ return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
2552
+ }
2553
+
2554
+ _peek(key, cache) {
2555
+ const item = cache.get(key);
2556
+
2557
+ return this._getItemValue(key, item);
2558
+ }
2559
+
2560
+ _set(key, value) {
2561
+ this.cache.set(key, value);
2562
+ this._size++;
2563
+
2564
+ if (this._size >= this.maxSize) {
2519
2565
  this._size = 0;
2566
+ this._emitEvictions(this.oldCache);
2567
+ this.oldCache = this.cache;
2568
+ this.cache = new Map();
2520
2569
  }
2570
+ }
2521
2571
 
2522
- _set(key, value) {
2523
- this.cache.set(key, value);
2524
- this._size++;
2572
+ _moveToRecent(key, item) {
2573
+ this.oldCache.delete(key);
2574
+ this._set(key, item);
2575
+ }
2525
2576
 
2526
- if (this._size >= this.maxSize) {
2527
- this._size = 0;
2528
- this.oldCache = this.cache;
2529
- this.cache = new Map();
2577
+ * _entriesAscending() {
2578
+ for (const item of this.oldCache) {
2579
+ const [key, value] = item;
2580
+ if (!this.cache.has(key)) {
2581
+ const deleted = this._deleteIfExpired(key, value);
2582
+ if (deleted === false) {
2583
+ yield item;
2584
+ }
2530
2585
  }
2531
2586
  }
2532
2587
 
2533
- get(key) {
2534
- if (this.cache.has(key)) {
2535
- return this.cache.get(key);
2588
+ for (const item of this.cache) {
2589
+ const [key, value] = item;
2590
+ const deleted = this._deleteIfExpired(key, value);
2591
+ if (deleted === false) {
2592
+ yield item;
2536
2593
  }
2594
+ }
2595
+ }
2537
2596
 
2538
- if (this.oldCache.has(key)) {
2539
- const value = this.oldCache.get(key);
2540
- this.oldCache.delete(key);
2541
- this._set(key, value);
2542
- return value;
2543
- }
2597
+ get(key) {
2598
+ if (this.cache.has(key)) {
2599
+ const item = this.cache.get(key);
2600
+
2601
+ return this._getItemValue(key, item);
2544
2602
  }
2545
2603
 
2546
- set(key, value) {
2547
- if (this.cache.has(key)) {
2548
- this.cache.set(key, value);
2549
- } else {
2550
- this._set(key, value);
2604
+ if (this.oldCache.has(key)) {
2605
+ const item = this.oldCache.get(key);
2606
+ if (this._deleteIfExpired(key, item) === false) {
2607
+ this._moveToRecent(key, item);
2608
+ return item.value;
2551
2609
  }
2610
+ }
2611
+ }
2552
2612
 
2553
- return this;
2613
+ set(key, value, {maxAge = this.maxAge} = {}) {
2614
+ const expiry =
2615
+ typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY ?
2616
+ Date.now() + maxAge :
2617
+ undefined;
2618
+ if (this.cache.has(key)) {
2619
+ this.cache.set(key, {
2620
+ value,
2621
+ expiry
2622
+ });
2623
+ } else {
2624
+ this._set(key, {value, expiry});
2554
2625
  }
2555
2626
 
2556
- has(key) {
2557
- return this.cache.has(key) || this.oldCache.has(key);
2627
+ return this;
2628
+ }
2629
+
2630
+ has(key) {
2631
+ if (this.cache.has(key)) {
2632
+ return !this._deleteIfExpired(key, this.cache.get(key));
2558
2633
  }
2559
2634
 
2560
- peek(key) {
2561
- if (this.cache.has(key)) {
2562
- return this.cache.get(key);
2563
- }
2635
+ if (this.oldCache.has(key)) {
2636
+ return !this._deleteIfExpired(key, this.oldCache.get(key));
2637
+ }
2564
2638
 
2565
- if (this.oldCache.has(key)) {
2566
- return this.oldCache.get(key);
2567
- }
2639
+ return false;
2640
+ }
2641
+
2642
+ peek(key) {
2643
+ if (this.cache.has(key)) {
2644
+ return this._peek(key, this.cache);
2568
2645
  }
2569
2646
 
2570
- delete(key) {
2571
- const deleted = this.cache.delete(key);
2572
- if (deleted) {
2573
- this._size--;
2574
- }
2647
+ if (this.oldCache.has(key)) {
2648
+ return this._peek(key, this.oldCache);
2649
+ }
2650
+ }
2651
+
2652
+ delete(key) {
2653
+ const deleted = this.cache.delete(key);
2654
+ if (deleted) {
2655
+ this._size--;
2656
+ }
2657
+
2658
+ return this.oldCache.delete(key) || deleted;
2659
+ }
2660
+
2661
+ clear() {
2662
+ this.cache.clear();
2663
+ this.oldCache.clear();
2664
+ this._size = 0;
2665
+ }
2575
2666
 
2576
- return this.oldCache.delete(key) || deleted;
2667
+ resize(newSize) {
2668
+ if (!(newSize && newSize > 0)) {
2669
+ throw new TypeError('`maxSize` must be a number greater than 0');
2577
2670
  }
2578
2671
 
2579
- clear() {
2580
- this.cache.clear();
2581
- this.oldCache.clear();
2672
+ const items = [...this._entriesAscending()];
2673
+ const removeCount = items.length - newSize;
2674
+ if (removeCount < 0) {
2675
+ this.cache = new Map(items);
2676
+ this.oldCache = new Map();
2677
+ this._size = items.length;
2678
+ } else {
2679
+ if (removeCount > 0) {
2680
+ this._emitEvictions(items.slice(0, removeCount));
2681
+ }
2682
+
2683
+ this.oldCache = new Map(items.slice(removeCount));
2684
+ this.cache = new Map();
2582
2685
  this._size = 0;
2583
2686
  }
2584
2687
 
2585
- * keys() {
2586
- for (const [key] of this) {
2587
- yield key;
2688
+ this.maxSize = newSize;
2689
+ }
2690
+
2691
+ * keys() {
2692
+ for (const [key] of this) {
2693
+ yield key;
2694
+ }
2695
+ }
2696
+
2697
+ * values() {
2698
+ for (const [, value] of this) {
2699
+ yield value;
2700
+ }
2701
+ }
2702
+
2703
+ * [Symbol.iterator]() {
2704
+ for (const item of this.cache) {
2705
+ const [key, value] = item;
2706
+ const deleted = this._deleteIfExpired(key, value);
2707
+ if (deleted === false) {
2708
+ yield [key, value.value];
2588
2709
  }
2589
2710
  }
2590
2711
 
2591
- * values() {
2592
- for (const [, value] of this) {
2593
- yield value;
2712
+ for (const item of this.oldCache) {
2713
+ const [key, value] = item;
2714
+ if (!this.cache.has(key)) {
2715
+ const deleted = this._deleteIfExpired(key, value);
2716
+ if (deleted === false) {
2717
+ yield [key, value.value];
2718
+ }
2594
2719
  }
2595
2720
  }
2721
+ }
2596
2722
 
2597
- * [Symbol.iterator]() {
2598
- for (const item of this.cache) {
2599
- yield item;
2723
+ * entriesDescending() {
2724
+ let items = [...this.cache];
2725
+ for (let i = items.length - 1; i >= 0; --i) {
2726
+ const item = items[i];
2727
+ const [key, value] = item;
2728
+ const deleted = this._deleteIfExpired(key, value);
2729
+ if (deleted === false) {
2730
+ yield [key, value.value];
2600
2731
  }
2732
+ }
2601
2733
 
2602
- for (const item of this.oldCache) {
2603
- const [key] = item;
2604
- if (!this.cache.has(key)) {
2605
- yield item;
2734
+ items = [...this.oldCache];
2735
+ for (let i = items.length - 1; i >= 0; --i) {
2736
+ const item = items[i];
2737
+ const [key, value] = item;
2738
+ if (!this.cache.has(key)) {
2739
+ const deleted = this._deleteIfExpired(key, value);
2740
+ if (deleted === false) {
2741
+ yield [key, value.value];
2606
2742
  }
2607
2743
  }
2608
2744
  }
2745
+ }
2609
2746
 
2610
- get size() {
2611
- let oldCacheSize = 0;
2612
- for (const key of this.oldCache.keys()) {
2613
- if (!this.cache.has(key)) {
2614
- oldCacheSize++;
2615
- }
2747
+ * entriesAscending() {
2748
+ for (const [key, value] of this._entriesAscending()) {
2749
+ yield [key, value.value];
2750
+ }
2751
+ }
2752
+
2753
+ get size() {
2754
+ if (!this._size) {
2755
+ return this.oldCache.size;
2756
+ }
2757
+
2758
+ let oldCacheSize = 0;
2759
+ for (const key of this.oldCache.keys()) {
2760
+ if (!this.cache.has(key)) {
2761
+ oldCacheSize++;
2616
2762
  }
2763
+ }
2764
+
2765
+ return Math.min(this._size + oldCacheSize, this.maxSize);
2766
+ }
2767
+
2768
+ entries() {
2769
+ return this.entriesAscending();
2770
+ }
2617
2771
 
2618
- return this._size + oldCacheSize;
2772
+ forEach(callbackFunction, thisArgument = this) {
2773
+ for (const [key, value] of this.entriesAscending()) {
2774
+ callbackFunction.call(thisArgument, value, key, this);
2619
2775
  }
2620
2776
  }
2621
2777
 
2622
- quickLru = QuickLRU;
2623
- return quickLru;
2778
+ get [Symbol.toStringTag]() {
2779
+ return JSON.stringify([...this.entriesAscending()]);
2780
+ }
2624
2781
  }
2625
2782
 
2626
- var quickLruExports = requireQuickLru();
2627
- var QuickLRU = /*@__PURE__*/getDefaultExportFromCjs(quickLruExports);
2628
-
2629
2783
  /*
2630
2784
  Hebcal - A Jewish Calendar Generator
2631
2785
  Copyright (c) 1994-2020 Danny Sadinoff