<|start_filename|>src/JulianDay.js<|end_filename|>
import { EPOCH } from "./constants/Time";

/**
 * Julian day from Gregorian date.
 * @param {Date} date Gregorian date to convert to Julian day.
 * @returns {number} Julian Day
 */
export const fromDate = (date = new Date()) => {
  const time = date.getTime();
  return time / 86400000 - date.getTimezoneOffset() / 1440 + EPOCH;
};

/**
 * Gregorian date from Julian day
 * @param {number} julian Julian dat to convert to Gregorian date
 * @returns {Date} Gregorian date
 */
export const toDate = (julian) => {
  let date = new Date();
  date.setTime((julian - EPOCH + date.getTimezoneOffset() / 1440) * 86400000);
  return date;
};


<|start_filename|>src/index.js<|end_filename|>
export { Hemisphere } from "./constants/Hemisphere";
export { LunarEmoji } from "./constants/LunarEmoji";
export { LunarPhase } from "./constants/LunarPhase";
export * as Time from "./constants/Time";
export * as Moon from "./Moon";
export * as JulianDay from "./JulianDay";


<|start_filename|>src/constants/LunarPhase.js<|end_filename|>
/**
 * Enumeration of lunar phases
 *
 * @typedef {string} LunarPhase
 * @enum {LunarPhase}
 */
export const LunarPhase = {
  NEW: "New",
  WAXING_CRESCENT: "Waxing Crescent",
  FIRST_QUARTER: "First Quarter",
  WAXING_GIBBOUS: "Waxing Gibbous",
  FULL: "Full",
  WANING_GIBBOUS: "Waning Gibbous",
  LAST_QUARTER: "Last Quarter",
  WANING_CRESCENT: "Waning Crescent",
};


<|start_filename|>src/utils/MathUtil.js<|end_filename|>
/**
 * Normalization utility for percentage calculations.
 *
 * @param {number} value Percent value.
 * @returns {number} Normalized value
 */
export const normalize = (value) => {
  value -= Math.floor(value);
  if (value < 0) {
    value += 1;
  }

  return value;
};


<|start_filename|>src/constants/LunarEmoji.js<|end_filename|>
/**
 * Enumeration of lunar phases as emoji.
 * @typedef {string} LunarEmoji
 */
export const LunarEmoji = {
  /**
   * Enumeration of lunar phases as emoji for the Northern Hemisphere.
   * @num {LunarPhase}
   */
  NorthernHemisphere: {
    NEW: "🌑",
    WAXING_CRESCENT: "🌒",
    FIRST_QUARTER: "🌓",
    WAXING_GIBBOUS: "🌔",
    FULL: "🌕",
    WANING_GIBBOUS: "🌖",
    LAST_QUARTER: "🌗",
    WANING_CRESCENT: "🌘",
  },

  /**
   * Enumeration of lunar phases as emoji for the Southern Hemisphere.
   * @num {LunarPhase}
   */
  SouthernHemisphere: {
    NEW: "🌑",
    WAXING_CRESCENT: "🌘",
    FIRST_QUARTER: "🌗",
    WAXING_GIBBOUS: "🌖",
    FULL: "🌕",
    WANING_GIBBOUS: "🌔",
    LAST_QUARTER: "🌓",
    WANING_CRESCENT: "🌒",
  },
};


<|start_filename|>package.json<|end_filename|>
{
  "name": "lunarphase-js",
  "version": "1.0.8",
  "description": "Calculate phase of the moon using Julian date",
  "author": "<NAME> <<EMAIL>> (https://jasonsturges.com)",
  "homepage": "https://jasonsturges.github.io/lunarphase-js/",
  "repository": {
    "type": "git",
    "url": "https://github.com/jasonsturges/lunarphase-js"
  },
  "license": "ISC",
  "keywords": [
    "astronomy",
    "moon",
    "lunar",
    "phase"
  ],
  "main": "dist/lunarphase-js.cjs.js",
  "module": "dist/lunarphase-js.esm.js",
  "browser": "dist/lunarphase-js.umd.js",
  "files": [
    "dist"
  ],
  "scripts": {
    "dev": "rollup -c -w",
    "build": "rollup -c",
    "predocs": "rimraf ./docs",
    "docs": "jsdoc -r src/*s -R README.md -d ./docs",
    "clean": "rimraf ./dist ./docs",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "@rollup/plugin-commonjs": "^19.0.0",
    "@rollup/plugin-node-resolve": "^13.0.0",
    "eslint": "^7.26.0",
    "prettier": "^2.3.0",
    "rimraf": "^3.0.2",
    "rollup": "^2.48.0"
  }
}
