Zorbing

suncalc.d.ts

Mar 10th, 2019
10,572
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Type definitions for suncalc 1.8.0
  2. // Project: https://www.npmjs.com/package/suncalc
  3. // Definitions by: Zorbing <https://github.com/Zorbing>
  4.  
  5. /* =================== USAGE ===================
  6.  
  7.     import * as SunCalc from "suncalc";
  8.  
  9.  =============================================== */
  10.  
  11. declare module "suncalc"
  12. {
  13.     /**
  14.      * Adds a custom time when the sun reaches the given angle to results returned by `SunCalc.getTimes`.
  15.      * `SunCalc.times` property contains all currently defined times.
  16.      */
  17.     function addTime(angle: number, riseName: string, setName: string): void;
  18.  
  19.     /**
  20.      * Returns the sun position at the given date, time, and position.
  21.      */
  22.     function getPosition(date: Date, latitude: number, longitude: number): {
  23.         /**
  24.          * Sun altitude above the horizon in radians, e.g. `0` at the horizon and `PI/2` at the zenith (straight over your head)
  25.          */
  26.         altitude: number;
  27.         /**
  28.          * Sun azimuth in radians (direction along the horizon, measured from south to west), e.g. `0` is south and `Math.PI * 3/4` is northwest
  29.          */
  30.         azimuth: number;
  31.     };
  32.  
  33.     /**
  34.      * Returns a times-object where each property is a `Date` object.
  35.      */
  36.     function getTimes(date: Date, latitude: number, longitude: number): {
  37.         /**
  38.          * Sunrise - top edge of the sun appears on the horizon
  39.          */
  40.         sunrise: Date;
  41.         /**
  42.          * Sunrise ends - bottom edge of the sun touches the horizon
  43.          */
  44.         sunriseEnd: Date;
  45.         /**
  46.          * Morning golden hour ends - soft light, best time for photography
  47.          */
  48.         goldenHourEnd: Date;
  49.         /**
  50.          * Solar noon - sun is in the highest position
  51.          */
  52.         solarNoon: Date;
  53.         /**
  54.          * Evening golden hour starts
  55.          */
  56.         goldenHour: Date;
  57.         /**
  58.          * Sunset starts - bottom edge of the sun touches the horizon
  59.          */
  60.         sunsetStart: Date;
  61.         /**
  62.          * Sunset - sun disappears below the horizon, evening civil twilight starts
  63.          */
  64.         sunset: Date;
  65.         /**
  66.          * Dusk - evening nautical twilight starts
  67.          */
  68.         dusk: Date;
  69.         /**
  70.          * Nautical dusk - evening astronomical twilight starts
  71.          */
  72.         nauticalDusk: Date;
  73.         /**
  74.          * Night starts - dark enough for astronomical observations
  75.          */
  76.         night: Date;
  77.         /**
  78.          * Nadir - darkest moment of the night, sun is in the lowest position
  79.          */
  80.         nadir: Date;
  81.         /**
  82.          * Night ends - morning astronomical twilight starts
  83.          */
  84.         nightEnd: Date;
  85.         /**
  86.          * Nautical dawn - morning nautical twilight starts
  87.          */
  88.         nauticalDawn: Date;
  89.         /**
  90.          * Dawn - morning nautical twilight ends, morning civil twilight starts
  91.          */
  92.         dawn: Date;
  93.     };
  94.  
  95.     /**
  96.      * Returns the moon position at the given date, time, and position.
  97.      */
  98.     function getMoonPosition(timeAndDate: Date, latitude: number, longitude: number): {
  99.         /**
  100.          * Moon altitude above the horizon in radians
  101.          */
  102.         altitude: number;
  103.         /**
  104.          * Moon azimuth in radians
  105.          */
  106.         azimuth: number;
  107.         /**
  108.          * Distance to moon in kilometers
  109.          */
  110.         distance: number;
  111.         /**
  112.          * Parallactic angle of the moon in radians
  113.          */
  114.         parallacticAngle: number;
  115.     };
  116.  
  117.     /**
  118.      * Returns the moon illumination at the given date and time.
  119.      *
  120.      * By subtracting the `parallacticAngle` from the `angle` one can get the zenith angle of the moons bright limb (anticlockwise).
  121.      * The zenith angle can be used do draw the moon shape from the observers perspective (e.g. moon lying on its back).
  122.      */
  123.     function getMoonIllumination(timeAndDate: Date): {
  124.         /**
  125.          * Illuminated fraction of the moon; varies from `0.0` (new moon) to `1.0` (full moon)
  126.          */
  127.         fraction: number;
  128.         /**
  129.          * Moon phase; varies from `0.0` to `1.0`.
  130.          * From New Moon (`0`) -> Waxing Crescent -> First Quarter (`0.25`) -> Waxing Gibbous -> Full Moon (`0.5`) -> Waning Gibbous -> Last Quarter (`0.75`) -> Waning Crescent
  131.          */
  132.         phase: number;
  133.         /**
  134.          * Midpoint angle in radians of the illuminated limb of the moon reckoned eastward from the north point of the disk; the moon is waxing if the angle is negative, and waning if positive
  135.          */
  136.         angle: number;
  137.     };
  138.  
  139.     /**
  140.      * Returns the moon times (kind of equivalent to `getTimes`).
  141.      *
  142.      * By default, it will search for moon rise and set during local user's day (frou 0 to 24 hours).
  143.      * If `inUTC` is set to `true`, it will instead search the specified date from 0 to 24 UTC hours.
  144.      */
  145.     function getMoonTimes(date: Date, latitude: number, longitude: number, inUTC?: boolean): {
  146.         /**
  147.          * Moonrise time as `Date`
  148.          */
  149.         rise?: Date;
  150.         /**
  151.          * Moonset time as `Date`
  152.          */
  153.         set?: Date;
  154.         /**
  155.          * `true` if the moon never rises/sets and is always _above_ the horizon during the day
  156.          */
  157.         alwaysUp?: boolean;
  158.         /**
  159.          * `true` if the moon is always _below_ the horizon
  160.          */
  161.         alwaysDown?: boolean;
  162.     };
  163. }
Advertisement
Comments
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment