@hebcal/core 3.33.4 → 3.33.5

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.js CHANGED
@@ -1,8 +1,23 @@
1
- /*! @hebcal/core v3.33.4 */
1
+ /*! @hebcal/core v3.33.5 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
+ function _defineProperty(obj, key, value) {
7
+ if (key in obj) {
8
+ Object.defineProperty(obj, key, {
9
+ value: value,
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true
13
+ });
14
+ } else {
15
+ obj[key] = value;
16
+ }
17
+
18
+ return obj;
19
+ }
20
+
6
21
  /*
7
22
  Hebcal - A Jewish Calendar Generator
8
23
  Copyright (c) 1994-2020 Danny Sadinoff
@@ -46,53 +61,54 @@ function quotient(x, y) {
46
61
  }
47
62
  /**
48
63
  * Gregorian date helper functions.
49
- * @namespace
50
64
  */
51
65
 
52
66
 
53
- const greg = {
67
+ class greg {
54
68
  /**
55
69
  * Long names of the Gregorian months (1='January', 12='December')
56
70
  * @readonly
57
71
  * @type {string[]}
58
72
  */
59
- monthNames: ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
60
73
 
61
74
  /**
62
75
  * Returns true if the Gregorian year is a leap year
63
76
  * @param {number} year Gregorian year
64
77
  * @return {boolean}
65
78
  */
66
- isLeapYear: function (year) {
79
+ static isLeapYear(year) {
67
80
  return !(year % 4) && (!!(year % 100) || !(year % 400));
68
- },
69
-
81
+ }
70
82
  /**
71
83
  * Number of days in the Gregorian month for given year
72
84
  * @param {number} month Gregorian month (1=January, 12=December)
73
85
  * @param {number} year Gregorian year
74
86
  * @return {number}
75
87
  */
76
- daysInMonth: function (month, year) {
88
+
89
+
90
+ static daysInMonth(month, year) {
77
91
  // 1 based months
78
92
  return monthLengths[+this.isLeapYear(year)][month];
79
- },
80
-
93
+ }
81
94
  /**
82
95
  * Returns true if the object is a Javascript Date
83
96
  * @param {Object} obj
84
97
  * @return {boolean}
85
98
  */
86
- isDate: function (obj) {
87
- return typeof obj === 'object' && Date.prototype === obj.__proto__;
88
- },
89
99
 
100
+
101
+ static isDate(obj) {
102
+ return typeof obj === 'object' && Date.prototype === obj.__proto__;
103
+ }
90
104
  /**
91
105
  * Returns number of days since January 1 of that year
92
106
  * @param {Date} date Gregorian date
93
107
  * @return {number}
94
108
  */
95
- dayOfYear: function (date) {
109
+
110
+
111
+ static dayOfYear(date) {
96
112
  if (!this.isDate(date)) {
97
113
  throw new TypeError('Argument to greg.dayOfYear not a Date');
98
114
  }
@@ -109,14 +125,15 @@ const greg = {
109
125
  }
110
126
 
111
127
  return doy;
112
- },
113
-
128
+ }
114
129
  /**
115
130
  * Converts Gregorian date to absolute R.D. (Rata Die) days
116
131
  * @param {Date} date Gregorian date
117
132
  * @return {number}
118
133
  */
119
- greg2abs: function (date) {
134
+
135
+
136
+ static greg2abs(date) {
120
137
  if (!this.isDate(date)) {
121
138
  throw new TypeError('Argument to greg.greg2abs not a Date');
122
139
  }
@@ -127,14 +144,15 @@ const greg = {
127
144
  Math.floor(year / 4) - // + Julian Leap years
128
145
  Math.floor(year / 100) + // - century years
129
146
  Math.floor(year / 400)); // + Gregorian leap years
130
- },
131
-
147
+ }
132
148
  /**
133
149
  * @private
134
150
  * @param {number} theDate - R.D. number of days
135
151
  * @return {number}
136
152
  */
137
- yearFromFixed: function (theDate) {
153
+
154
+
155
+ static yearFromFixed(theDate) {
138
156
  const l0 = theDate - 1;
139
157
  const n400 = quotient(l0, 146097);
140
158
  const d1 = mod(l0, 146097);
@@ -145,8 +163,7 @@ const greg = {
145
163
  const n1 = quotient(d3, 365);
146
164
  const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
147
165
  return n100 != 4 && n1 != 4 ? year + 1 : year;
148
- },
149
-
166
+ }
150
167
  /**
151
168
  * @private
152
169
  * @param {number} year
@@ -154,11 +171,12 @@ const greg = {
154
171
  * @param {number} day
155
172
  * @return {number}
156
173
  */
157
- toFixed: function (year, month, day) {
174
+
175
+
176
+ static toFixed(year, month, day) {
158
177
  const py = year - 1;
159
178
  return 0 + 365 * py + quotient(py, 4) - quotient(py, 100) + quotient(py, 400) + quotient(367 * month - 362, 12) + Math.floor(month <= 2 ? 0 : this.isLeapYear(year) ? -1 : -2) + day;
160
- },
161
-
179
+ }
162
180
  /**
163
181
  * Converts from Rata Die (R.D. number) to Gregorian date.
164
182
  * See the footnote on page 384 of ``Calendrical Calculations, Part II:
@@ -168,7 +186,9 @@ const greg = {
168
186
  * @param {number} theDate - R.D. number of days
169
187
  * @return {Date}
170
188
  */
171
- abs2greg: function (theDate) {
189
+
190
+
191
+ static abs2greg(theDate) {
172
192
  if (typeof theDate !== 'number') {
173
193
  throw new TypeError('Argument to greg.abs2greg not a Number');
174
194
  }
@@ -187,7 +207,10 @@ const greg = {
187
207
 
188
208
  return dt;
189
209
  }
190
- };
210
+
211
+ }
212
+
213
+ _defineProperty(greg, "monthNames", ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
191
214
 
192
215
  const GERESH = '׳';
193
216
  const GERSHAYIM = '״';
@@ -375,18 +398,14 @@ const alias = {
375
398
  * * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
376
399
  * * `he` - Hebrew (e.g. "שַׁבָּת")
377
400
  * * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
378
- * @namespace
379
401
  */
380
402
 
381
- const Locale = {
403
+ class Locale {
382
404
  /** @private */
383
- locales: Object.create(null),
384
405
 
385
406
  /** @private */
386
- activeLocale: null,
387
407
 
388
408
  /** @private */
389
- activeName: null,
390
409
 
391
410
  /**
392
411
  * Returns translation only if `locale` offers a non-empty translation for `id`.
@@ -395,7 +414,7 @@ const Locale = {
395
414
  * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
396
415
  * @return {string}
397
416
  */
398
- lookupTranslation: function lookupTranslation(id, locale) {
417
+ static lookupTranslation(id, locale) {
399
418
  const locale0 = locale && locale.toLowerCase();
400
419
  const loc = typeof locale == 'string' && this.locales[locale0] || this.activeLocale;
401
420
  const array = loc[id];
@@ -405,15 +424,16 @@ const Locale = {
405
424
  }
406
425
 
407
426
  return undefined;
408
- },
409
-
427
+ }
410
428
  /**
411
429
  * By default, if no translation was found, returns `id`.
412
430
  * @param {string} id Message ID to translate
413
431
  * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
414
432
  * @return {string}
415
433
  */
416
- gettext: function gettext(id, locale) {
434
+
435
+
436
+ static gettext(id, locale) {
417
437
  const text = this.lookupTranslation(id, locale);
418
438
 
419
439
  if (typeof text == 'undefined') {
@@ -421,21 +441,21 @@ const Locale = {
421
441
  }
422
442
 
423
443
  return text;
424
- },
425
-
444
+ }
426
445
  /**
427
446
  * Register locale translations.
428
447
  * @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
429
448
  * @param {LocaleDate} data parsed data from a `.po` file.
430
449
  */
431
- addLocale: function addLocale(locale, data) {
450
+
451
+
452
+ static addLocale(locale, data) {
432
453
  if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
433
454
  throw new TypeError(`Locale '${locale}' invalid compact format`);
434
455
  }
435
456
 
436
457
  this.locales[locale.toLowerCase()] = data.contexts[''];
437
- },
438
-
458
+ }
439
459
  /**
440
460
  * Activates a locale. Throws an error if the locale has not been previously added.
441
461
  * After setting the locale to be used, all strings marked for translations
@@ -443,7 +463,9 @@ const Locale = {
443
463
  * @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
444
464
  * @return {LocaleData}
445
465
  */
446
- useLocale: function useLocale(locale) {
466
+
467
+
468
+ static useLocale(locale) {
447
469
  const locale0 = locale.toLowerCase();
448
470
  const obj = this.locales[locale0];
449
471
 
@@ -454,30 +476,33 @@ const Locale = {
454
476
  this.activeName = alias[locale0] || locale0;
455
477
  this.activeLocale = obj;
456
478
  return this.activeLocale;
457
- },
458
-
479
+ }
459
480
  /**
460
481
  * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
461
482
  * @return {string}
462
483
  */
463
- getLocaleName: function getLocaleName() {
464
- return this.activeName;
465
- },
466
484
 
485
+
486
+ static getLocaleName() {
487
+ return this.activeName;
488
+ }
467
489
  /**
468
490
  * Returns the names of registered locales
469
491
  * @return {string[]}
470
492
  */
471
- getLocaleNames: function getLocaleNames() {
472
- return Object.keys(this.locales).sort();
473
- },
474
493
 
494
+
495
+ static getLocaleNames() {
496
+ return Object.keys(this.locales).sort();
497
+ }
475
498
  /**
476
499
  * @param {number} n
477
500
  * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
478
501
  * @return {string}
479
502
  */
480
- ordinal: function ordinal(n, locale) {
503
+
504
+
505
+ static ordinal(n, locale) {
481
506
  const locale1 = locale && locale.toLowerCase();
482
507
  const locale0 = locale1 || this.activeName;
483
508
 
@@ -506,28 +531,38 @@ const Locale = {
506
531
  default:
507
532
  return n + '.';
508
533
  }
509
- },
510
-
534
+ }
511
535
  /**
512
536
  * @private
513
537
  * @param {number} n
514
538
  * @return {string}
515
539
  */
516
- getEnOrdinal: function getEnOrdinal(n) {
540
+
541
+
542
+ static getEnOrdinal(n) {
517
543
  const s = ['th', 'st', 'nd', 'rd'];
518
544
  const v = n % 100;
519
545
  return n + (s[(v - 20) % 10] || s[v] || s[0]);
520
- },
521
-
546
+ }
522
547
  /**
523
548
  * Removes nekudot from Hebrew string
524
549
  * @param {string} str
525
550
  * @return {string}
526
551
  */
527
- hebrewStripNikkud: function hebrewStripNikkud(str) {
552
+
553
+
554
+ static hebrewStripNikkud(str) {
528
555
  return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
529
556
  }
530
- };
557
+
558
+ }
559
+
560
+ _defineProperty(Locale, "locales", Object.create(null));
561
+
562
+ _defineProperty(Locale, "activeLocale", null);
563
+
564
+ _defineProperty(Locale, "activeName", null);
565
+
531
566
  Locale.addLocale('en', noopLocale);
532
567
  Locale.addLocale('s', noopLocale);
533
568
  Locale.addLocale('', noopLocale);
@@ -3056,7 +3091,7 @@ const TZEIT_3MEDIUM_STARS = 7.083;
3056
3091
  * @param {HDate} hd
3057
3092
  * @param {number} dow
3058
3093
  * @param {Location} location
3059
- * @param {HebrewCalendar.Options} options
3094
+ * @param {CalOptions} options
3060
3095
  * @return {Event}
3061
3096
  */
3062
3097
 
@@ -5002,7 +5037,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
5002
5037
  return new HDate(day, month, hyear);
5003
5038
  }
5004
5039
 
5005
- var version="3.33.4";
5040
+ var version="3.33.5";
5006
5041
 
5007
5042
  var headers$1={"plural-forms":"nplurals=2; plural=(n > 1);",language:"en_CA@ashkenazi"};var contexts$1={"":{Berachot:["Berachos"],Shabbat:["Shabbos"],Taanit:["Taanis"],Yevamot:["Yevamos"],Ketubot:["Kesubos"],"Baba Batra":["Baba Basra"],Makkot:["Makkos"],Shevuot:["Shevuos"],Horayot:["Horayos"],Menachot:["Menachos"],Bechorot:["Bechoros"],Keritot:["Kerisos"],Midot:["Midos"],"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"],Tazria:["Sazria"],"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"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],Berakhot:["Berakhos"],Sheviit:["Sheviis"],Terumot:["Terumos"],Maasrot:["Maasros"],Eduyot:["Eduyos"],Avot:["Avos"],Bekhorot:["Bekhoros"],Middot:["Middos"],Oholot:["Oholos"],Tahorot:["Tahoros"],Mikvaot:["Mikvaos"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
5008
5043
 
@@ -5112,7 +5147,7 @@ const RECOGNIZED_OPTIONS = {
5112
5147
  };
5113
5148
  /**
5114
5149
  * @private
5115
- * @param {HebrewCalendar.Options} options
5150
+ * @param {CalOptions} options
5116
5151
  */
5117
5152
 
5118
5153
  function warnUnrecognizedOptions(options) {
@@ -5139,7 +5174,7 @@ function shallowCopy(target, source) {
5139
5174
  /**
5140
5175
  * Modifies options in-place
5141
5176
  * @private
5142
- * @param {HebrewCalendar.Options} options
5177
+ * @param {CalOptions} options
5143
5178
  */
5144
5179
 
5145
5180
 
@@ -5174,7 +5209,7 @@ function checkCandleOptions(options) {
5174
5209
  }
5175
5210
  /**
5176
5211
  * Options to configure which events are returned
5177
- * @typedef {Object} HebrewCalendar.Options
5212
+ * @typedef {Object} CalOptions
5178
5213
  * @property {Location} location - latitude/longitude/tzid used for candle-lighting
5179
5214
  * @property {number} year - Gregorian or Hebrew year
5180
5215
  * @property {boolean} isHebrewYear - to interpret year as Hebrew year
@@ -5230,7 +5265,7 @@ function getAbs(d) {
5230
5265
  /**
5231
5266
  * Parse options object to determine start & end days
5232
5267
  * @private
5233
- * @param {HebrewCalendar.Options} options
5268
+ * @param {CalOptions} options
5234
5269
  * @return {number[]}
5235
5270
  */
5236
5271
 
@@ -5307,7 +5342,7 @@ function getStartAndEnd(options) {
5307
5342
  /**
5308
5343
  * Mask to filter Holiday array
5309
5344
  * @private
5310
- * @param {HebrewCalendar.Options} options
5345
+ * @param {CalOptions} options
5311
5346
  * @return {number}
5312
5347
  */
5313
5348
 
@@ -5431,7 +5466,7 @@ function observedInDiaspora(ev) {
5431
5466
 
5432
5467
  class HebrewCalendar {
5433
5468
  /**
5434
- * Calculates holidays and other Hebrew calendar events based on {@link HebrewCalendar.Options}.
5469
+ * Calculates holidays and other Hebrew calendar events based on {@link CalOptions}.
5435
5470
  *
5436
5471
  * Each holiday is represented by an {@link Event} object which includes a date,
5437
5472
  * a description, flags and optional attributes.
@@ -5527,7 +5562,7 @@ class HebrewCalendar {
5527
5562
  * const date = hd.greg();
5528
5563
  * console.log(date.toLocaleDateString(), ev.render(), hd.toString());
5529
5564
  * }
5530
- * @param {HebrewCalendar.Options} [options={}]
5565
+ * @param {CalOptions} [options={}]
5531
5566
  * @return {Event[]}
5532
5567
  */
5533
5568
  static calendar(options = {}) {
@@ -5792,11 +5827,11 @@ class HebrewCalendar {
5792
5827
  }
5793
5828
  /**
5794
5829
  * Helper function to format a 23-hour (00:00-23:59) time in US format ("8:13pm") or
5795
- * keep as "20:13" for any other locale/country. Uses `HebrewCalendar.Options` to determine
5830
+ * keep as "20:13" for any other locale/country. Uses `CalOptions` to determine
5796
5831
  * locale.
5797
5832
  * @param {string} timeStr - original time like "20:30"
5798
5833
  * @param {string} suffix - "p" or "pm" or " P.M.". Add leading space if you want it
5799
- * @param {HebrewCalendar.Options} options
5834
+ * @param {CalOptions} options
5800
5835
  * @return {string}
5801
5836
  */
5802
5837
 
@@ -5847,7 +5882,7 @@ class HebrewCalendar {
5847
5882
  * @private
5848
5883
  * @param {Event[]} events
5849
5884
  * @param {Event} ev
5850
- * @param {HebrewCalendar.Options} options
5885
+ * @param {CalOptions} options
5851
5886
  * @param {Event} candlesEv
5852
5887
  * @param {number} dow
5853
5888
  * @return {Event}