@hebcal/core 5.0.0 → 5.0.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 v5.0.0 */
1
+ /*! @hebcal/core v5.0.1 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -29,10 +29,9 @@ const heb2num = {
29
29
  'ת': 400
30
30
  };
31
31
  const num2heb = new Map();
32
- Object.keys(heb2num).forEach(key => {
33
- const val = heb2num[key];
32
+ for (const [key, val] of Object.entries(heb2num)) {
34
33
  num2heb.set(val, key);
35
- });
34
+ }
36
35
 
37
36
  /**
38
37
  * @private
@@ -252,9 +251,7 @@ class Locale {
252
251
  throw new TypeError(`Locale '${locale}' invalid compact format`);
253
252
  }
254
253
  const ctx = data.contexts[''];
255
- Object.keys(ctx).forEach(id => {
256
- loc[id] = ctx[id];
257
- });
254
+ Object.assign(loc, ctx);
258
255
  }
259
256
  /**
260
257
  * Activates a locale. Throws an error if the locale has not been previously added.
@@ -1784,7 +1781,7 @@ class Event {
1784
1781
  this.desc = desc;
1785
1782
  this.mask = +mask;
1786
1783
  if (typeof attrs === 'object' && attrs !== null) {
1787
- Object.keys(attrs).forEach(k => this[k] = attrs[k]);
1784
+ Object.assign(this, attrs);
1788
1785
  }
1789
1786
  }
1790
1787
  /**
@@ -6574,10 +6571,10 @@ class Location extends GeoLocation {
6574
6571
  return true;
6575
6572
  }
6576
6573
  }
6577
- classicCities0.forEach(city => {
6574
+ for (const city of classicCities0) {
6578
6575
  const location = new Location(city[2], city[3], city[1] == 'IL', city[4], city[0], city[1], undefined, city[5]);
6579
6576
  Location.addLocation(location.getName(), location);
6580
- });
6577
+ }
6581
6578
 
6582
6579
  const _formatters = new Map();
6583
6580
 
@@ -9490,40 +9487,7 @@ const MINOR_HOLIDAY$1 = flags.MINOR_HOLIDAY;
9490
9487
  const EREV$1 = flags.EREV;
9491
9488
  // const CHOL_HAMOED = flags.CHOL_HAMOED;
9492
9489
 
9493
- /**
9494
- * Avoid dependency on ES6 Map object
9495
- * @private
9496
- */
9497
- class SimpleMap {
9498
- /**
9499
- * @param {string} key
9500
- * @return {boolean}
9501
- */
9502
- has(key) {
9503
- return typeof this[key] !== 'undefined';
9504
- }
9505
- /**
9506
- * @param {string} key
9507
- * @return {any}
9508
- */
9509
- get(key) {
9510
- return this[key];
9511
- }
9512
- /**
9513
- * @param {string} key
9514
- * @param {any} val
9515
- */
9516
- set(key, val) {
9517
- this[key] = val;
9518
- }
9519
- /**
9520
- * @return {string[]}
9521
- */
9522
- keys() {
9523
- return Object.keys(this);
9524
- }
9525
- }
9526
- const sedraCache = new SimpleMap();
9490
+ const sedraCache = new Map();
9527
9491
 
9528
9492
  /**
9529
9493
  * @private
@@ -9567,16 +9531,15 @@ function getHolidaysForYear_(year) {
9567
9531
  }
9568
9532
  const RH = new HDate(1, TISHREI$1, year);
9569
9533
  const pesach = new HDate(15, NISAN$1, year);
9570
- const h = new SimpleMap();
9534
+ const map = new Map();
9571
9535
  // eslint-disable-next-line require-jsdoc
9572
9536
  function add() {
9573
9537
  for (var _len = arguments.length, events = new Array(_len), _key = 0; _key < _len; _key++) {
9574
9538
  events[_key] = arguments[_key];
9575
9539
  }
9576
- // for (const ev of events) {
9577
- events.forEach(ev => {
9540
+ for (const ev of events) {
9578
9541
  const key = ev.date.toString();
9579
- const arr = h.get(key);
9542
+ const arr = map.get(key);
9580
9543
  if (typeof arr === 'object') {
9581
9544
  if (arr[0].getFlags() & flags.EREV) {
9582
9545
  arr.unshift(ev);
@@ -9584,17 +9547,17 @@ function getHolidaysForYear_(year) {
9584
9547
  arr.push(ev);
9585
9548
  }
9586
9549
  } else {
9587
- h.set(key, [ev]);
9550
+ map.set(key, [ev]);
9588
9551
  }
9589
- });
9552
+ }
9590
9553
  }
9591
- staticHolidays.forEach(h => {
9554
+ for (const h of staticHolidays) {
9592
9555
  const hd = new HDate(h.dd, h.mm, year);
9593
9556
  const ev = new HolidayEvent(hd, h.desc, h.flags);
9594
9557
  if (h.emoji) ev.emoji = h.emoji;
9595
9558
  if (h.chmDay) ev.cholHaMoedDay = h.chmDay;
9596
9559
  add(ev);
9597
- });
9560
+ }
9598
9561
 
9599
9562
  // standard holidays that don't shift based on year
9600
9563
  add(new RoshHashanaEvent(RH, year, CHAG | LIGHT_CANDLES_TZEIS$1));
@@ -9646,7 +9609,7 @@ function getHolidaysForYear_(year) {
9646
9609
  if (yomHaZikaronDt) {
9647
9610
  add(new HolidayEvent(yomHaZikaronDt, 'Yom HaZikaron', MODERN_HOLIDAY$1, emojiIsraelFlag), new HolidayEvent(yomHaZikaronDt.next(), 'Yom HaAtzma\'ut', MODERN_HOLIDAY$1, emojiIsraelFlag));
9648
9611
  }
9649
- staticModernHolidays.forEach(h => {
9612
+ for (const h of staticModernHolidays) {
9650
9613
  if (year >= h.firstYear) {
9651
9614
  let hd = new HDate(h.dd, h.mm, year);
9652
9615
  const dow = hd.getDay();
@@ -9664,7 +9627,7 @@ function getHolidaysForYear_(year) {
9664
9627
  }
9665
9628
  add(ev);
9666
9629
  }
9667
- });
9630
+ }
9668
9631
  let tamuz17 = new HDate(17, TAMUZ, year);
9669
9632
  let tamuz17attrs;
9670
9633
  if (tamuz17.getDay() == SAT$1) {
@@ -9735,8 +9698,8 @@ function getHolidaysForYear_(year) {
9735
9698
  emoji: '☀️'
9736
9699
  }));
9737
9700
  }
9738
- yearCache.set(year, h);
9739
- return h;
9701
+ yearCache.set(year, map);
9702
+ return map;
9740
9703
  }
9741
9704
 
9742
9705
  /**
@@ -9803,7 +9766,7 @@ class DailyLearning {
9803
9766
  }
9804
9767
  }
9805
9768
 
9806
- const version="5.0.0";
9769
+ const version="5.0.1";
9807
9770
 
9808
9771
  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};
9809
9772
 
@@ -9816,9 +9779,9 @@ Locale.addLocale('he', poHe);
9816
9779
  Locale.addLocale('h', poHe);
9817
9780
  const heStrs = poHe.contexts[''];
9818
9781
  const heNoNikud = {};
9819
- Object.keys(heStrs).forEach(key => {
9820
- heNoNikud[key] = [Locale.hebrewStripNikkud(heStrs[key][0])];
9821
- });
9782
+ for (const [key, val] of Object.entries(heStrs)) {
9783
+ heNoNikud[key] = [Locale.hebrewStripNikkud(val[0])];
9784
+ }
9822
9785
  const poHeNoNikud = {
9823
9786
  headers: poHe.headers,
9824
9787
  contexts: {
@@ -10611,24 +10574,12 @@ const RECOGNIZED_OPTIONS = {
10611
10574
  * @param {CalOptions} options
10612
10575
  */
10613
10576
  function warnUnrecognizedOptions(options) {
10614
- Object.keys(options).forEach(k => {
10577
+ for (const k of Object.keys(options)) {
10615
10578
  if (typeof RECOGNIZED_OPTIONS[k] === 'undefined' && !unrecognizedAlreadyWarned.has(k)) {
10616
10579
  console.warn(`Ignoring unrecognized HebrewCalendar option: ${k}`);
10617
10580
  unrecognizedAlreadyWarned.add(k);
10618
10581
  }
10619
- });
10620
- }
10621
-
10622
- /**
10623
- * A bit like Object.assign(), but just a shallow copy
10624
- * @private
10625
- * @param {any} target
10626
- * @param {any} source
10627
- * @return {any}
10628
- */
10629
- function shallowCopy(target, source) {
10630
- Object.keys(source).forEach(k => target[k] = source[k]);
10631
- return target;
10582
+ }
10632
10583
  }
10633
10584
  const israelCityOffset = {
10634
10585
  'Jerusalem': 40,
@@ -11107,7 +11058,7 @@ class HebrewCalendar {
11107
11058
  */
11108
11059
  static calendar() {
11109
11060
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11110
- options = shallowCopy({}, options); // so we can modify freely
11061
+ options = Object.assign({}, options); // so we can modify freely
11111
11062
  checkCandleOptions(options);
11112
11063
  const location = options.location = options.location || defaultLocation;
11113
11064
  const il = options.il = options.il || location.il || false;
@@ -11156,9 +11107,9 @@ class HebrewCalendar {
11156
11107
  const dow = hd.getDay();
11157
11108
  let candlesEv;
11158
11109
  const ev = holidaysYear.get(hd.toString()) || [];
11159
- ev.forEach(e => {
11110
+ for (const e of ev) {
11160
11111
  candlesEv = appendHolidayAndRelated(evts, e, options, candlesEv, dow);
11161
- });
11112
+ }
11162
11113
  if (options.sedrot && dow === SAT) {
11163
11114
  const parsha0 = sedra.lookup(abs);
11164
11115
  if (!parsha0.chag) {
@@ -11167,8 +11118,7 @@ class HebrewCalendar {
11167
11118
  }
11168
11119
  const dailyLearning = options.dailyLearning;
11169
11120
  if (typeof dailyLearning === 'object') {
11170
- Object.keys(dailyLearning).forEach(key => {
11171
- const val = dailyLearning[key];
11121
+ for (const [key, val] of Object.entries(dailyLearning)) {
11172
11122
  if (val) {
11173
11123
  const name = key === 'yerushalmi' ? val === 2 ? 'yerushalmi-schottenstein' : 'yerushalmi-vilna' : key;
11174
11124
  const learningEv = DailyLearning.lookup(name, hd);
@@ -11176,7 +11126,7 @@ class HebrewCalendar {
11176
11126
  evts.push(learningEv);
11177
11127
  }
11178
11128
  }
11179
- });
11129
+ }
11180
11130
  }
11181
11131
  if (options.omer && abs >= beginOmer && abs <= endOmer) {
11182
11132
  const omer = abs - beginOmer + 1;