@hebcal/core 4.3.5 → 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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.3.5 */
1
+ /*! @hebcal/core v4.4.1 */
2
2
  /*
3
3
  * More minimal greg routines
4
4
  */
@@ -323,8 +323,8 @@ function gematriya(number) {
323
323
  const thousands = Math.floor(num / 1000);
324
324
  if (thousands > 0 && thousands !== 5) {
325
325
  const tdigits = num2digits(thousands);
326
- for (let i = 0; i < tdigits.length; i++) {
327
- str += num2heb[tdigits[i]];
326
+ for (const tdig of tdigits) {
327
+ str += num2heb[tdig];
328
328
  }
329
329
  str += GERESH;
330
330
  }
@@ -359,8 +359,8 @@ function gematriyaStrToNum(str) {
359
359
  num += gematriyaStrToNum(thousands) * 1000;
360
360
  str = str.substring(gereshIdx);
361
361
  }
362
- for (let i = 0; i < str.length; i++) {
363
- const n = heb2num[str[i]];
362
+ for (const ch of str) {
363
+ const n = heb2num[ch];
364
364
  if (typeof n === 'number') {
365
365
  num += n;
366
366
  }
@@ -407,7 +407,7 @@ class Locale {
407
407
  * @return {string}
408
408
  */
409
409
  static lookupTranslation(id, locale) {
410
- const locale0 = locale && locale.toLowerCase();
410
+ const locale0 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
411
411
  const loc = typeof locale == 'string' && locales[locale0] || activeLocale;
412
412
  const array = loc[id];
413
413
  if (array && array.length && array[0].length) {
@@ -527,7 +527,7 @@ class Locale {
527
527
  * @return {string[]}
528
528
  */
529
529
  static getLocaleNames() {
530
- return Object.keys(locales).sort();
530
+ return Object.keys(locales).sort((a, b) => a.localeCompare(b));
531
531
  }
532
532
 
533
533
  /**
@@ -536,7 +536,7 @@ class Locale {
536
536
  * @return {string}
537
537
  */
538
538
  static ordinal(n, locale) {
539
- const locale1 = locale && locale.toLowerCase();
539
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
540
540
  const locale0 = locale1 || activeName;
541
541
  if (!locale0) {
542
542
  return this.getEnOrdinal(n);
@@ -1201,7 +1201,7 @@ class HDate {
1201
1201
  if (ofStr) {
1202
1202
  return ' ' + ofStr;
1203
1203
  }
1204
- if ('ashkenazi' === locale.substring(0, 9)) {
1204
+ if (locale.startsWith('ashkenazi')) {
1205
1205
  return ' of';
1206
1206
  }
1207
1207
  return '';
@@ -1590,9 +1590,7 @@ class HDate {
1590
1590
  return months.ADAR_I;
1591
1591
  }
1592
1592
  return months.ADAR_II;
1593
- // else assume sheini
1594
1593
  }
1595
-
1596
1594
  break;
1597
1595
  case 'ס':
1598
1596
  return months.SIVAN;
@@ -1951,8 +1949,7 @@ class Event {
1951
1949
  */
1952
1950
  getCategories() {
1953
1951
  const mask = this.getFlags();
1954
- for (let i = 0; i < flagToCategory.length; i++) {
1955
- const attrs = flagToCategory[i];
1952
+ for (const attrs of flagToCategory) {
1956
1953
  if (mask & attrs[0]) {
1957
1954
  return attrs.slice(1);
1958
1955
  }
@@ -1981,7 +1978,7 @@ class HebrewDateEvent extends Event {
1981
1978
  * @return {string}
1982
1979
  */
1983
1980
  render(locale) {
1984
- const locale1 = locale && locale.toLowerCase();
1981
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
1985
1982
  const locale0 = locale1 || Locale.getLocaleName();
1986
1983
  const hd = this.getDate();
1987
1984
  switch (locale0) {
@@ -2008,7 +2005,7 @@ class HebrewDateEvent extends Event {
2008
2005
  * @return {string}
2009
2006
  */
2010
2007
  renderBrief(locale) {
2011
- const locale1 = locale && locale.toLowerCase();
2008
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
2012
2009
  const locale0 = locale1 || Locale.getLocaleName();
2013
2010
  const hd = this.getDate();
2014
2011
  if (hd.getMonth() === months.TISHREI && hd.getDate() === 1) {
@@ -3307,7 +3304,7 @@ function makeFastStartEnd(ev, location) {
3307
3304
  if (desc === 'Erev Tish\'a B\'Av') {
3308
3305
  const sunset = zmanim.sunset();
3309
3306
  ev.startEvent = makeTimedEvent(hd, sunset, 'Fast begins', ev, location);
3310
- } else if (desc.substring(0, 11) === 'Tish\'a B\'Av') {
3307
+ } else if (desc.startsWith('Tish\'a B\'Av')) {
3311
3308
  ev.endEvent = makeTimedEvent(hd, zmanim.tzeit(TZEIT_3MEDIUM_STARS), 'Fast ends', ev, location);
3312
3309
  } else {
3313
3310
  const dawn = zmanim.alotHaShachar();
@@ -4612,16 +4609,6 @@ const staticModernHolidays = [{
4612
4609
 
4613
4610
  /** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
4614
4611
  class HolidayEvent extends Event {
4615
- /**
4616
- * Constructs Holiday event
4617
- * @param {HDate} date Hebrew date event occurs
4618
- * @param {string} desc Description (not translated)
4619
- * @param {number} [mask=0] optional holiday flags
4620
- * @param {Object} [attrs={}]
4621
- */
4622
- constructor(date, desc, mask, attrs) {
4623
- super(date, desc, mask, attrs);
4624
- }
4625
4612
  /** @return {string} */
4626
4613
  basename() {
4627
4614
  return this.getDesc().replace(/ \d{4}$/, '').replace(/ \(CH''M\)$/, '').replace(/ \(observed\)$/, '').replace(/ \(Hoshana Raba\)$/, '').replace(/ [IV]+$/, '').replace(/: \d Candles?$/, '').replace(/: 8th Day$/, '').replace(/^Erev /, '');
@@ -4713,15 +4700,6 @@ class RoshChodeshEvent extends HolidayEvent {
4713
4700
  * we subclass HolidayEvent to override the `url()` method.
4714
4701
  */
4715
4702
  class AsaraBTevetEvent extends HolidayEvent {
4716
- /**
4717
- * Constructs AsaraBTevetEvent
4718
- * @param {HDate} date Hebrew date event occurs
4719
- * @param {string} desc Description (not translated)
4720
- * @param {number} [mask=0] optional holiday flags
4721
- */
4722
- constructor(date, desc, mask) {
4723
- super(date, desc, mask);
4724
- }
4725
4703
  /** @return {string} */
4726
4704
  urlDateSuffix() {
4727
4705
  const isoDateTime = this.getDate().greg().toISOString();
@@ -5257,7 +5235,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
5257
5235
  return new HDate(day, month, hyear);
5258
5236
  }
5259
5237
 
5260
- const version="4.3.5";
5238
+ const version="4.4.1";
5261
5239
 
5262
5240
  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};
5263
5241
 
@@ -5452,9 +5430,9 @@ function tachanunYear(year, il) {
5452
5430
  );
5453
5431
 
5454
5432
  return {
5455
- none: none.map(hd => hd.abs()).sort(),
5456
- some: some.map(hd => hd.abs()).sort(),
5457
- yesPrev: yesPrev.map(hd => hd.abs()).sort()
5433
+ none: none.map(hd => hd.abs()).sort((a, b) => a - b),
5434
+ some: some.map(hd => hd.abs()).sort((a, b) => a - b),
5435
+ yesPrev: yesPrev.map(hd => hd.abs()).sort((a, b) => a - b)
5458
5436
  };
5459
5437
  }
5460
5438
 
@@ -5591,7 +5569,7 @@ function checkCandleOptions(options) {
5591
5569
  return;
5592
5570
  }
5593
5571
  const location = options.location;
5594
- if (typeof location === 'undefined' || !location instanceof Location) {
5572
+ if (typeof location === 'undefined' || !(location instanceof Location)) {
5595
5573
  throw new TypeError('options.candlelighting requires valid options.location');
5596
5574
  }
5597
5575
  if (typeof options.havdalahMins === 'number' && typeof options.havdalahDeg === 'number') {
@@ -5758,6 +5736,7 @@ function getStartAndEnd(options) {
5758
5736
  * @return {number}
5759
5737
  */
5760
5738
  function getMaskFromOptions(options) {
5739
+ var _options$location;
5761
5740
  if (typeof options.mask === 'number') {
5762
5741
  const m = options.mask;
5763
5742
  if (m & ROSH_CHODESH) delete options.noRoshChodesh;
@@ -5787,7 +5766,7 @@ function getMaskFromOptions(options) {
5787
5766
  options.userMask = true;
5788
5767
  return m;
5789
5768
  }
5790
- const il = options.il || options.location && options.location.il || false;
5769
+ const il = options.il || ((_options$location = options.location) === null || _options$location === void 0 ? void 0 : _options$location.il) || false;
5791
5770
  let mask = 0;
5792
5771
 
5793
5772
  // default options
@@ -6045,7 +6024,7 @@ class HebrewCalendar {
6045
6024
  }
6046
6025
  const prevEventsLength = evts.length;
6047
6026
  const dow = hd.getDay();
6048
- let candlesEv = undefined;
6027
+ let candlesEv;
6049
6028
  const ev = holidaysYear.get(hd.toString()) || [];
6050
6029
  ev.forEach(e => {
6051
6030
  candlesEv = appendHolidayAndRelated(evts, e, options, candlesEv, dow);
@@ -6249,8 +6228,9 @@ class HebrewCalendar {
6249
6228
  * @return {string}
6250
6229
  */
6251
6230
  static reformatTimeStr(timeStr, suffix, options) {
6231
+ var _options$location2;
6252
6232
  if (typeof timeStr !== 'string') throw new TypeError(`Bad timeStr: ${timeStr}`);
6253
- const cc = options.location && options.location.cc || (options.il ? 'IL' : 'US');
6233
+ const cc = ((_options$location2 = options.location) === null || _options$location2 === void 0 ? void 0 : _options$location2.cc) || (options.il ? 'IL' : 'US');
6254
6234
  if (typeof options.hour12 !== 'undefined' && !options.hour12) {
6255
6235
  return timeStr;
6256
6236
  }
@@ -6386,9 +6366,7 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
6386
6366
  candlesEv = undefined;
6387
6367
  }
6388
6368
  }
6389
- if (options.yomKippurKatan && eFlags & flags.YOM_KIPPUR_KATAN) {
6390
- events.push(ev);
6391
- } else if (!options.noHolidays) {
6369
+ if (!options.noHolidays || options.yomKippurKatan && eFlags & flags.YOM_KIPPUR_KATAN) {
6392
6370
  events.push(ev); // the original event itself
6393
6371
  }
6394
6372
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/core",
3
- "version": "4.3.5",
3
+ "version": "4.4.1",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "contributors": [
6
6
  "Eyal Schachter (https://github.com/Scimonster)",
@@ -22,13 +22,9 @@
22
22
  "description": "A perpetual Jewish Calendar API",
23
23
  "main": "./dist/index.js",
24
24
  "module": "./dist/index.mjs",
25
- "exports": {
26
- "import": "./dist/index.mjs",
27
- "require": "./dist/index.js"
28
- },
29
25
  "typings": "hebcal.d.ts",
30
26
  "engines": {
31
- "node": ">= 12.17.0"
27
+ "node": ">= 16.0.0"
32
28
  },
33
29
  "repository": {
34
30
  "type": "git",
@@ -65,23 +61,23 @@
65
61
  "verbose": true
66
62
  },
67
63
  "devDependencies": {
68
- "@babel/core": "^7.23.0",
69
- "@babel/preset-env": "^7.22.20",
64
+ "@babel/core": "^7.23.2",
65
+ "@babel/preset-env": "^7.23.2",
70
66
  "@babel/register": "^7.22.15",
71
67
  "@hebcal/solar-calc": "^1.1.2",
72
- "@rollup/plugin-babel": "^6.0.3",
73
- "@rollup/plugin-commonjs": "^25.0.4",
74
- "@rollup/plugin-json": "^6.0.0",
75
- "@rollup/plugin-node-resolve": "^15.2.1",
76
- "@rollup/plugin-terser": "^0.4.3",
68
+ "@rollup/plugin-babel": "^6.0.4",
69
+ "@rollup/plugin-commonjs": "^25.0.7",
70
+ "@rollup/plugin-json": "^6.0.1",
71
+ "@rollup/plugin-node-resolve": "^15.2.3",
72
+ "@rollup/plugin-terser": "^0.4.4",
77
73
  "ava": "^5.3.1",
78
74
  "core-js": "^3.33.0",
79
- "eslint": "^8.50.0",
75
+ "eslint": "^8.51.0",
80
76
  "eslint-config-google": "^0.14.0",
81
77
  "jsdoc": "^4.0.2",
82
78
  "jsdoc-to-markdown": "^8.0.0",
83
79
  "nyc": "^15.1.0",
84
- "rollup": "^3.29.4",
80
+ "rollup": "^4.1.4",
85
81
  "ttag-cli": "^1.10.6"
86
82
  }
87
83
  }