@hebcal/noaa 0.8.5 → 0.8.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/README.md CHANGED
@@ -66,7 +66,7 @@ GeoLocation constructor with parameters for all required fields.
66
66
  | --- | --- | --- |
67
67
  | name | <code>string</code> | The location name for display use such as &quot;Lakewood, NJ&quot; |
68
68
  | latitude | <code>number</code> | the latitude in a double format such as 40.095965 for Lakewood, NJ. <b>Note: </b> For latitudes south of the equator, a negative value should be used. |
69
- | longitude | <code>number</code> | double the longitude in a double format such as -74.222130 for Lakewood, NJ. <b>Note: </b> For longitudes east of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime Meridian </a> (Greenwich), a negative value should be used. |
69
+ | longitude | <code>number</code> | double the longitude in a double format such as -74.222130 for Lakewood, NJ. <b>Note: </b> For longitudes west of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime Meridian </a> (Greenwich), a negative value should be used. |
70
70
  | elevation | <code>number</code> | the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating sunrise and set. |
71
71
  | timeZoneId | <code>string</code> | the <code>TimeZone</code> for the location. |
72
72
 
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NOAACalculator = exports.GeoLocation = void 0;
4
- const temporal_polyfill_1 = require("temporal-polyfill");
4
+ (async () => {
5
+ if (typeof Temporal !== 'function') {
6
+ await Promise.resolve().then(() => require('temporal-polyfill/global'));
7
+ }
8
+ })();
5
9
  /**
6
10
  * java.lang.Math.toRadians
7
11
  * @private
@@ -39,7 +43,7 @@ class GeoLocation {
39
43
  * <b>Note: </b> For latitudes south of the equator, a negative value should be used.
40
44
  * @param {number} longitude
41
45
  * double the longitude in a double format such as -74.222130 for Lakewood, NJ.
42
- * <b>Note: </b> For longitudes east of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
46
+ * <b>Note: </b> For longitudes west of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
43
47
  * Meridian </a> (Greenwich), a negative value should be used.
44
48
  * @param {number} elevation
45
49
  * the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating
@@ -85,6 +89,11 @@ class GeoLocation {
85
89
  this.elevation = elevation;
86
90
  }
87
91
  setLatitude(latitude) {
92
+ if (typeof latitude !== 'number')
93
+ throw new TypeError('Invalid latitude');
94
+ if (latitude < -90 || latitude > 90) {
95
+ throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);
96
+ }
88
97
  this.latitude = latitude;
89
98
  }
90
99
  /**
@@ -94,6 +103,11 @@ class GeoLocation {
94
103
  return this.latitude;
95
104
  }
96
105
  setLongitude(longitude) {
106
+ if (typeof longitude !== 'number')
107
+ throw new TypeError('Invalid longitude');
108
+ if (longitude < -180 || longitude > 180) {
109
+ throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
110
+ }
97
111
  this.longitude = longitude;
98
112
  }
99
113
  /**
@@ -652,7 +666,7 @@ class NOAACalculator {
652
666
  return cal
653
667
  .toZonedDateTime({
654
668
  timeZone: 'UTC',
655
- plainTime: new temporal_polyfill_1.Temporal.PlainTime(hours, minutes, seconds, Math.trunc(calculatedTime * 1000)),
669
+ plainTime: new Temporal.PlainTime(hours, minutes, seconds, Math.trunc(calculatedTime * 1000)),
656
670
  })
657
671
  .withTimeZone(this.geoLocation.getTimeZone());
658
672
  }
package/dist/esm/index.js CHANGED
@@ -1,4 +1,20 @@
1
- import { Temporal } from 'temporal-polyfill';
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.NOAACalculator = exports.GeoLocation = void 0;
13
+ (() => __awaiter(void 0, void 0, void 0, function* () {
14
+ if (typeof Temporal !== 'function') {
15
+ yield import('temporal-polyfill/global');
16
+ }
17
+ }))();
2
18
  /**
3
19
  * java.lang.Math.toRadians
4
20
  * @private
@@ -25,7 +41,7 @@ const Long_MIN_VALUE = NaN;
25
41
  * @author &copy; Eliyahu Hershfeld 2004 - 2016
26
42
  * @version 1.1
27
43
  */
28
- export class GeoLocation {
44
+ class GeoLocation {
29
45
  /**
30
46
  * GeoLocation constructor with parameters for all required fields.
31
47
  *
@@ -36,7 +52,7 @@ export class GeoLocation {
36
52
  * <b>Note: </b> For latitudes south of the equator, a negative value should be used.
37
53
  * @param {number} longitude
38
54
  * double the longitude in a double format such as -74.222130 for Lakewood, NJ.
39
- * <b>Note: </b> For longitudes east of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
55
+ * <b>Note: </b> For longitudes west of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
40
56
  * Meridian </a> (Greenwich), a negative value should be used.
41
57
  * @param {number} elevation
42
58
  * the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating
@@ -82,6 +98,11 @@ export class GeoLocation {
82
98
  this.elevation = elevation;
83
99
  }
84
100
  setLatitude(latitude) {
101
+ if (typeof latitude !== 'number')
102
+ throw new TypeError('Invalid latitude');
103
+ if (latitude < -90 || latitude > 90) {
104
+ throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);
105
+ }
85
106
  this.latitude = latitude;
86
107
  }
87
108
  /**
@@ -91,6 +112,11 @@ export class GeoLocation {
91
112
  return this.latitude;
92
113
  }
93
114
  setLongitude(longitude) {
115
+ if (typeof longitude !== 'number')
116
+ throw new TypeError('Invalid longitude');
117
+ if (longitude < -180 || longitude > 180) {
118
+ throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
119
+ }
94
120
  this.longitude = longitude;
95
121
  }
96
122
  /**
@@ -133,6 +159,7 @@ export class GeoLocation {
133
159
  this.timeZoneId = timeZoneId;
134
160
  }
135
161
  }
162
+ exports.GeoLocation = GeoLocation;
136
163
  /**
137
164
  * The commonly used average solar refraction. Calendrical Calculations lists a more accurate global average of
138
165
  * 34.478885263888294
@@ -164,7 +191,7 @@ const earthRadius = 6356.9; // in KM
164
191
  *
165
192
  * @author &copy; Eliyahu Hershfeld 2011 - 2019
166
193
  */
167
- export class NOAACalculator {
194
+ class NOAACalculator {
168
195
  /**
169
196
  * A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
170
197
  * parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
@@ -1040,6 +1067,7 @@ export class NOAACalculator {
1040
1067
  return timeUTC;
1041
1068
  }
1042
1069
  }
1070
+ exports.NOAACalculator = NOAACalculator;
1043
1071
  /**
1044
1072
  * The zenith of astronomical sunrise and sunset. The sun is 90&deg; from the vertical 0&deg;
1045
1073
  * @private
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Temporal } from 'temporal-polyfill';
2
1
  /**
3
2
  * A class that contains location information such as latitude and longitude required for astronomical calculations. The
4
3
  * elevation field may not be used by some calculation engines and would be ignored if set. Check the documentation for
@@ -19,7 +18,7 @@ export declare class GeoLocation {
19
18
  * <b>Note: </b> For latitudes south of the equator, a negative value should be used.
20
19
  * @param {number} longitude
21
20
  * double the longitude in a double format such as -74.222130 for Lakewood, NJ.
22
- * <b>Note: </b> For longitudes east of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
21
+ * <b>Note: </b> For longitudes west of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
23
22
  * Meridian </a> (Greenwich), a negative value should be used.
24
23
  * @param {number} elevation
25
24
  * the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/noaa",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "description": "sunrise and sunset via NOAA algorithm with elevation, based on KosherJava",
5
5
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
6
6
  "contributors": [
@@ -40,11 +40,9 @@
40
40
  "dist/*"
41
41
  ],
42
42
  "devDependencies": {
43
- "@types/node": "20.9.3",
43
+ "@types/node": "20.10.0",
44
44
  "gts": "^5.2.0",
45
+ "temporal-polyfill": "^0.1.1",
45
46
  "typescript": "^5.3.2"
46
- },
47
- "dependencies": {
48
- "temporal-polyfill": "^0.1.1"
49
47
  }
50
48
  }