@hebcal/core 4.4.0 → 4.4.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.
package/dist/bundle.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.4.0 */
1
+ /*! @hebcal/core v4.4.1 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -326,8 +326,8 @@ function gematriya(number) {
326
326
  const thousands = Math.floor(num / 1000);
327
327
  if (thousands > 0 && thousands !== 5) {
328
328
  const tdigits = num2digits(thousands);
329
- for (let i = 0; i < tdigits.length; i++) {
330
- str += num2heb[tdigits[i]];
329
+ for (const tdig of tdigits) {
330
+ str += num2heb[tdig];
331
331
  }
332
332
  str += GERESH;
333
333
  }
@@ -362,8 +362,8 @@ function gematriyaStrToNum(str) {
362
362
  num += gematriyaStrToNum(thousands) * 1000;
363
363
  str = str.substring(gereshIdx);
364
364
  }
365
- for (let i = 0; i < str.length; i++) {
366
- const n = heb2num[str[i]];
365
+ for (const ch of str) {
366
+ const n = heb2num[ch];
367
367
  if (typeof n === 'number') {
368
368
  num += n;
369
369
  }
@@ -410,7 +410,7 @@ class Locale {
410
410
  * @return {string}
411
411
  */
412
412
  static lookupTranslation(id, locale) {
413
- const locale0 = locale && locale.toLowerCase();
413
+ const locale0 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
414
414
  const loc = typeof locale == 'string' && locales[locale0] || activeLocale;
415
415
  const array = loc[id];
416
416
  if (array && array.length && array[0].length) {
@@ -530,7 +530,7 @@ class Locale {
530
530
  * @return {string[]}
531
531
  */
532
532
  static getLocaleNames() {
533
- return Object.keys(locales).sort();
533
+ return Object.keys(locales).sort((a, b) => a.localeCompare(b));
534
534
  }
535
535
 
536
536
  /**
@@ -539,7 +539,7 @@ class Locale {
539
539
  * @return {string}
540
540
  */
541
541
  static ordinal(n, locale) {
542
- const locale1 = locale && locale.toLowerCase();
542
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
543
543
  const locale0 = locale1 || activeName;
544
544
  if (!locale0) {
545
545
  return this.getEnOrdinal(n);
@@ -1206,7 +1206,7 @@ class HDate {
1206
1206
  if (ofStr) {
1207
1207
  return ' ' + ofStr;
1208
1208
  }
1209
- if ('ashkenazi' === locale.substring(0, 9)) {
1209
+ if (locale.startsWith('ashkenazi')) {
1210
1210
  return ' of';
1211
1211
  }
1212
1212
  return '';
@@ -1598,9 +1598,7 @@ class HDate {
1598
1598
  return months.ADAR_I;
1599
1599
  }
1600
1600
  return months.ADAR_II;
1601
- // else assume sheini
1602
1601
  }
1603
-
1604
1602
  break;
1605
1603
  case 'ס':
1606
1604
  return months.SIVAN;
@@ -1960,8 +1958,7 @@ class Event {
1960
1958
  */
1961
1959
  getCategories() {
1962
1960
  const mask = this.getFlags();
1963
- for (let i = 0; i < flagToCategory.length; i++) {
1964
- const attrs = flagToCategory[i];
1961
+ for (const attrs of flagToCategory) {
1965
1962
  if (mask & attrs[0]) {
1966
1963
  return attrs.slice(1);
1967
1964
  }
@@ -1990,7 +1987,7 @@ class HebrewDateEvent extends Event {
1990
1987
  * @return {string}
1991
1988
  */
1992
1989
  render(locale) {
1993
- const locale1 = locale && locale.toLowerCase();
1990
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
1994
1991
  const locale0 = locale1 || Locale.getLocaleName();
1995
1992
  const hd = this.getDate();
1996
1993
  switch (locale0) {
@@ -2017,7 +2014,7 @@ class HebrewDateEvent extends Event {
2017
2014
  * @return {string}
2018
2015
  */
2019
2016
  renderBrief(locale) {
2020
- const locale1 = locale && locale.toLowerCase();
2017
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
2021
2018
  const locale0 = locale1 || Locale.getLocaleName();
2022
2019
  const hd = this.getDate();
2023
2020
  if (hd.getMonth() === months.TISHREI && hd.getDate() === 1) {
@@ -3283,7 +3280,7 @@ function makeFastStartEnd(ev, location) {
3283
3280
  if (desc === 'Erev Tish\'a B\'Av') {
3284
3281
  const sunset = zmanim.sunset();
3285
3282
  ev.startEvent = makeTimedEvent(hd, sunset, 'Fast begins', ev, location);
3286
- } else if (desc.substring(0, 11) === 'Tish\'a B\'Av') {
3283
+ } else if (desc.startsWith('Tish\'a B\'Av')) {
3287
3284
  ev.endEvent = makeTimedEvent(hd, zmanim.tzeit(TZEIT_3MEDIUM_STARS), 'Fast ends', ev, location);
3288
3285
  } else {
3289
3286
  const dawn = zmanim.alotHaShachar();
@@ -5314,16 +5311,6 @@ const staticModernHolidays = [{
5314
5311
 
5315
5312
  /** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
5316
5313
  class HolidayEvent extends Event {
5317
- /**
5318
- * Constructs Holiday event
5319
- * @param {HDate} date Hebrew date event occurs
5320
- * @param {string} desc Description (not translated)
5321
- * @param {number} [mask=0] optional holiday flags
5322
- * @param {Object} [attrs={}]
5323
- */
5324
- constructor(date, desc, mask, attrs) {
5325
- super(date, desc, mask, attrs);
5326
- }
5327
5314
  /** @return {string} */
5328
5315
  basename() {
5329
5316
  return this.getDesc().replace(/ \d{4}$/, '').replace(/ \(CH''M\)$/, '').replace(/ \(observed\)$/, '').replace(/ \(Hoshana Raba\)$/, '').replace(/ [IV]+$/, '').replace(/: \d Candles?$/, '').replace(/: 8th Day$/, '').replace(/^Erev /, '');
@@ -5415,15 +5402,6 @@ class RoshChodeshEvent extends HolidayEvent {
5415
5402
  * we subclass HolidayEvent to override the `url()` method.
5416
5403
  */
5417
5404
  class AsaraBTevetEvent extends HolidayEvent {
5418
- /**
5419
- * Constructs AsaraBTevetEvent
5420
- * @param {HDate} date Hebrew date event occurs
5421
- * @param {string} desc Description (not translated)
5422
- * @param {number} [mask=0] optional holiday flags
5423
- */
5424
- constructor(date, desc, mask) {
5425
- super(date, desc, mask);
5426
- }
5427
5405
  /** @return {string} */
5428
5406
  urlDateSuffix() {
5429
5407
  const isoDateTime = this.getDate().greg().toISOString();
@@ -5962,7 +5940,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
5962
5940
  return new HDate(day, month, hyear);
5963
5941
  }
5964
5942
 
5965
- const version="4.4.0";
5943
+ const version="4.4.1";
5966
5944
 
5967
5945
  const headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts$1={"":{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"],Tevet:["Teves"],"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"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
5968
5946
 
@@ -6669,9 +6647,9 @@ function tachanunYear(year, il) {
6669
6647
  );
6670
6648
 
6671
6649
  return {
6672
- none: none.map(hd => hd.abs()).sort(),
6673
- some: some.map(hd => hd.abs()).sort(),
6674
- yesPrev: yesPrev.map(hd => hd.abs()).sort()
6650
+ none: none.map(hd => hd.abs()).sort((a, b) => a - b),
6651
+ some: some.map(hd => hd.abs()).sort((a, b) => a - b),
6652
+ yesPrev: yesPrev.map(hd => hd.abs()).sort((a, b) => a - b)
6675
6653
  };
6676
6654
  }
6677
6655
 
@@ -6808,7 +6786,7 @@ function checkCandleOptions(options) {
6808
6786
  return;
6809
6787
  }
6810
6788
  const location = options.location;
6811
- if (typeof location === 'undefined' || !location instanceof Location) {
6789
+ if (typeof location === 'undefined' || !(location instanceof Location)) {
6812
6790
  throw new TypeError('options.candlelighting requires valid options.location');
6813
6791
  }
6814
6792
  if (typeof options.havdalahMins === 'number' && typeof options.havdalahDeg === 'number') {
@@ -6975,6 +6953,7 @@ function getStartAndEnd(options) {
6975
6953
  * @return {number}
6976
6954
  */
6977
6955
  function getMaskFromOptions(options) {
6956
+ var _options$location;
6978
6957
  if (typeof options.mask === 'number') {
6979
6958
  const m = options.mask;
6980
6959
  if (m & ROSH_CHODESH) delete options.noRoshChodesh;
@@ -7004,7 +6983,7 @@ function getMaskFromOptions(options) {
7004
6983
  options.userMask = true;
7005
6984
  return m;
7006
6985
  }
7007
- const il = options.il || options.location && options.location.il || false;
6986
+ const il = options.il || ((_options$location = options.location) === null || _options$location === void 0 ? void 0 : _options$location.il) || false;
7008
6987
  let mask = 0;
7009
6988
 
7010
6989
  // default options
@@ -7263,7 +7242,7 @@ class HebrewCalendar {
7263
7242
  }
7264
7243
  const prevEventsLength = evts.length;
7265
7244
  const dow = hd.getDay();
7266
- let candlesEv = undefined;
7245
+ let candlesEv;
7267
7246
  const ev = holidaysYear.get(hd.toString()) || [];
7268
7247
  ev.forEach(e => {
7269
7248
  candlesEv = appendHolidayAndRelated(evts, e, options, candlesEv, dow);
@@ -7467,8 +7446,9 @@ class HebrewCalendar {
7467
7446
  * @return {string}
7468
7447
  */
7469
7448
  static reformatTimeStr(timeStr, suffix, options) {
7449
+ var _options$location2;
7470
7450
  if (typeof timeStr !== 'string') throw new TypeError(`Bad timeStr: ${timeStr}`);
7471
- const cc = options.location && options.location.cc || (options.il ? 'IL' : 'US');
7451
+ const cc = ((_options$location2 = options.location) === null || _options$location2 === void 0 ? void 0 : _options$location2.cc) || (options.il ? 'IL' : 'US');
7472
7452
  if (typeof options.hour12 !== 'undefined' && !options.hour12) {
7473
7453
  return timeStr;
7474
7454
  }
@@ -7604,9 +7584,7 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
7604
7584
  candlesEv = undefined;
7605
7585
  }
7606
7586
  }
7607
- if (options.yomKippurKatan && eFlags & flags.YOM_KIPPUR_KATAN) {
7608
- events.push(ev);
7609
- } else if (!options.noHolidays) {
7587
+ if (!options.noHolidays || options.yomKippurKatan && eFlags & flags.YOM_KIPPUR_KATAN) {
7610
7588
  events.push(ev); // the original event itself
7611
7589
  }
7612
7590
  }