Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

suncalc3

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

suncalc3 - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

package.json
{
"name": "suncalc3",
"version": "2.0.2",
"version": "2.0.3",
"description": "A tiny JavaScript library for calculating sun/moon positions and phases.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/hypnos3/suncalc3",

@@ -16,3 +16,3 @@

as a part of the [SunCalc.net project](http://suncalc.net).
This version is reworked and enhanced by [@hypnos3](https://github.com/hypnos3)
This version is reworked and enhanced by [@hypnos3](https://github.com/hypnos3). The output of the function is changed in the most times to objects with enhanced properies.

@@ -33,3 +33,3 @@ Most calculations are based on the formulas given in the excellent Astronomy Answers articles

- [Sunlight times](#sunlight-times)
- [adding own Sunlight times](#adding-own-sunlight-times)
- [adding / getting own Sunlight times](#adding--getting-own-sunlight-times)
- [get specific Sunlight time](#get-specific-sunlight-time)

@@ -76,2 +76,4 @@ - [get Sunlight time for a given azimuth angle for a given date](#get-sunlight-time-for-a-given-azimuth-angle-for-a-given-date)

Additional are the output of the function is changed in the most times to objects with more properies. Also JSDOC is added ans type script definitions.
## Usage example

@@ -114,3 +116,3 @@

* @param {number} [height=0] the observer height (in meters) relative to the horizon
* @param {boolean} [addDeprecated=false] if true to times will be added to the object for old names
* @param {boolean} [addDeprecated=false] if true to times from timesDeprecated array will be added to the object
* @param {boolean} [inUTC=false] defines if the calculation should be in utc or local time (default is local)

@@ -225,3 +227,3 @@ * @return {ISunTimeList} result object of sunTime

#### adding own Sunlight times
#### adding / getting own Sunlight times

@@ -241,6 +243,29 @@ ```javascript

`SunCalc.times` property contains all currently defined times.
```javascript
/**
* @typedef ISunTimeNames
* @type {Object}
* @property {number} angle - angle of the sun position in degrees
* @property {string} riseName - name of sun rise (morning name)
* @property {string} setName - name of sun set (evening name)
* @property {number} [risePos] - (optional) position at rise
* @property {number} [setPos] - (optional) position at set
*/
```
`SunCalc.timesAlternate` property contains all deprecated time names.
`SunCalc.times` property contains all currently defined times of type `Array.<ISunTimeNames>`.
```javascript
/**
* add an alternate name for a sun time
* @param {string} alternameName - alternate or deprecated time name
* @param {string} originalName - original time name from SunCalc.times array
*/
SunCalc.addDeprecatedTimeName = function (alternameName, originalName) {
```
Add a deprecated name
`SunCalc.timesDeprecated` property contains all deprecated time names as an `Array.<[string, string]>` - `Array.<deprecatedname, originalName>`.
#### get specific Sunlight time

@@ -247,0 +272,0 @@

@@ -373,3 +373,3 @@ // @ts-check

*/
const sunTimesAlternate = SunCalc.timesAlternate = [
const suntimesDeprecated = SunCalc.timesDeprecated = [
['dawn', 'civilDawn'],

@@ -388,3 +388,3 @@ ['dusk', 'civilDusk'],

/** adds a custom time to the times config
* @param {number} angle - angle of the sun position in degrees
* @param {number} angleAltitude - angle of Altitude/elevation above the horizont of the sun in degrees
* @param {string} riseName - name of sun rise (morning name)

@@ -394,7 +394,18 @@ * @param {string} setName - name of sun set (evening name)

* @param {number} [setPos] - (optional) position at set (evening)
* @param {boolean} [degree=true] defines if the elevationAngle is in degree not in radians
*/
SunCalc.addTime = function (angle, riseName, setName, risePos, setPos) {
sunTimes.push({angle, riseName, setName, risePos, setPos});
SunCalc.addTime = function (angleAltitude, riseName, setName, risePos, setPos, degree) {
const angleDeg = (degree === false ? (angleAltitude * ( 180 / Math.PI )) : angleAltitude);
sunTimes.push({angle: angleDeg, riseName, setName, risePos, setPos});
};
/**
* add an alternate name for a sun time
* @param {string} alternameName - alternate or deprecated time name
* @param {string} originalName - original time name from SunCalc.times array
*/
SunCalc.addDeprecatedTimeName = function (alternameName, originalName) {
suntimesDeprecated.push([alternameName, originalName]);
};
// calculations for sun times

@@ -480,3 +491,3 @@

* @param {number} [height=0] the observer height (in meters) relative to the horizon
* @param {boolean} [addDeprecated=false] if true to times will be added to the object for old names
* @param {boolean} [addDeprecated=false] if true to times from timesDeprecated array will be added to the object
* @param {boolean} [inUTC=false] defines if the calculation should be in utc or local time (default is local)

@@ -579,4 +590,4 @@ * @return {ISunTimeList} result object of sunTime

// for backward compatibility
for (let i = 0, len = sunTimesAlternate.length; i < len; i += 1) {
const time = sunTimesAlternate[i];
for (let i = 0, len = suntimesDeprecated.length; i < len; i += 1) {
const time = suntimesDeprecated[i];
result[time[0]] = Object.assign({}, result[time[1]]);

@@ -583,0 +594,0 @@ result[time[0]].deprecated = true;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc