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

iztro

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iztro - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

23

CHANGELOG.md

@@ -10,5 +10,28 @@ # 紫微斗数

## v2.2.2
- 🛠️ 修复(fix)
🇨🇳
- 来因宫错误 #161
🇺🇸
- fix incorrect original palace data #161
- ✨ 改进(enhancement)
🇨🇳
- 更新lunar-lite依赖,以支持更宽的日期参数
🇺🇸
- upgrade lunar-lite dependency in order to support wilder date parameter
## v2.2.1
- 🛠️ 修复(fix)
🇨🇳

@@ -15,0 +38,0 @@

10

lib/astro/astro.d.ts

@@ -65,12 +65,2 @@ import { Language } from '../data/types';

/**
* 通过农历年份获取十二生肖
*
* @version v1.2.1
*
* @param year 农历年份
* @param language 输出语言,默认为中文
* @returns 十二生肖
*/
export declare const getZodiacByLunarYear: (year: number, language?: Language) => unknown;
/**
* 通过阳历获取星座

@@ -77,0 +67,0 @@ *

24

lib/astro/astro.js

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getMajorStarByLunarDate = exports.getMajorStarBySolarDate = exports.getSignByLunarDate = exports.getSignBySolarDate = exports.getZodiacByLunarYear = exports.getZodiacBySolarDate = exports.byLunar = exports.astrolabeByLunarDate = exports.bySolar = exports.astrolabeBySolarDate = void 0;
exports.getMajorStarByLunarDate = exports.getMajorStarBySolarDate = exports.getSignByLunarDate = exports.getSignBySolarDate = exports.getZodiacBySolarDate = exports.byLunar = exports.astrolabeByLunarDate = exports.bySolar = exports.astrolabeBySolarDate = void 0;
var lunar_lite_1 = require("lunar-lite");

@@ -49,2 +49,3 @@ var data_1 = require("../data");

var earthlyBranchOfYear = (0, i18n_1.kot)(yearly[1], 'Earthly');
var heavenlyStemOfYear = (0, i18n_1.kot)(yearly[0], 'Heavenly');
var _a = (0, palace_1.getSoulAndBody)(solarDateStr, timeIndex, fixLeap), bodyIndex = _a.bodyIndex, soulIndex = _a.soulIndex, heavenlyStemOfSoul = _a.heavenlyStemOfSoul, earthlyBranchOfSoul = _a.earthlyBranchOfSoul;

@@ -66,4 +67,3 @@ var palaceNames = (0, palace_1.getPalaceNames)(soulIndex);

isBodyPalace: bodyIndex === i,
isOriginalPalace: !['ziEarthly', 'chouEarthly'].includes(earthlyBranchOfPalace) &&
earthlyBranchOfPalace === earthlyBranchOfYear,
isOriginalPalace: !['ziEarthly', 'chouEarthly'].includes(earthlyBranchOfPalace) && heavenlyStemOfPalace === heavenlyStemOfYear,
heavenlyStem: (0, i18n_1.t)(heavenlyStemOfPalace),

@@ -155,4 +155,3 @@ earthlyBranch: (0, i18n_1.t)(earthlyBranchOfPalace),

language && (0, i18n_1.setLanguage)(language);
var lunarYear = (0, lunar_lite_1.solar2lunar)(solarDateStr).lunarYear;
var yearly = (0, lunar_lite_1.heavenlyStemAndEarthlyBranchOfYear)(lunarYear);
var yearly = (0, lunar_lite_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(solarDateStr, 0).yearly;
return (0, i18n_1.t)((0, i18n_1.kot)((0, lunar_lite_1.getZodiac)(yearly[1])));

@@ -162,17 +161,2 @@ };

/**
* 通过农历年份获取十二生肖
*
* @version v1.2.1
*
* @param year 农历年份
* @param language 输出语言,默认为中文
* @returns 十二生肖
*/
var getZodiacByLunarYear = function (year, language) {
language && (0, i18n_1.setLanguage)(language);
var yearly = (0, lunar_lite_1.heavenlyStemAndEarthlyBranchOfYear)(year);
return (0, i18n_1.t)((0, i18n_1.kot)((0, lunar_lite_1.getZodiac)(yearly[1])));
};
exports.getZodiacByLunarYear = getZodiacByLunarYear;
/**
* 通过阳历获取星座

@@ -179,0 +163,0 @@ *

@@ -249,3 +249,3 @@ import { EarthlyBranchName, HeavenlyStemName } from '../i18n';

*
* -安截路空亡
* - 安截路空亡
* - 甲己之年申酉,乙庚之年午未,

@@ -252,0 +252,0 @@ * - 丙辛之年辰巳,丁壬之年寅卯,

@@ -29,3 +29,3 @@ "use strict";

var _a = (0, astro_1.getSoulAndBody)(solarDateStr, timeIndex, fixLeap), heavenlyStemOfSoul = _a.heavenlyStemOfSoul, earthlyBranchOfSoul = _a.earthlyBranchOfSoul;
var _b = (0, lunar_lite_1.solar2lunar)(solarDateStr), lunarYear = _b.lunarYear, lunarMonth = _b.lunarMonth, lunarDay = _b.lunarDay;
var lunarDay = (0, lunar_lite_1.solar2lunar)(solarDateStr).lunarDay;
var fiveElements = (0, i18n_1.kot)((0, astro_1.getFiveElementsClass)(heavenlyStemOfSoul, earthlyBranchOfSoul));

@@ -36,3 +36,3 @@ var remainder = -1; // 余数

// 获取当月最大天数
var maxDays = (0, lunar_lite_1.getTotalDaysOfLunarMonth)(lunarYear, lunarMonth);
var maxDays = (0, lunar_lite_1.getTotalDaysOfLunarMonth)(solarDateStr);
// 如果timeIndex等于12说明是晚子时,需要加一天

@@ -518,3 +518,3 @@ var _day = timeIndex === 12 ? lunarDay + 1 : lunarDay;

*
* -安截路空亡
* - 安截路空亡
* - 甲己之年申酉,乙庚之年午未,

@@ -521,0 +521,0 @@ * - 丙辛之年辰巳,丁壬之年寅卯,

@@ -36,10 +36,2 @@ import { Brightness, EarthlyBranchName, HeavenlyStemName, Mutagen, StarName } from '../i18n';

/**
* 处理晚子时日期
*
* @param {string} solarDateStr 阳历日期
* @param {number} numbertimeIndex 时辰序号【0~12】,12代表晚子时
* @returns {LunarDate} LunarDate
*/
export declare const fixLunarDate: (solarDateStr: string, timeIndex: number) => import("lunar-lite/lib/types").LunarDate;
/**
* 调整农历月份的索引

@@ -46,0 +38,0 @@ *

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.translateChineseDate = exports.getAgeIndex = exports.timeToIndex = exports.mergeStars = exports.fixLunarDayIndex = exports.fixLunarMonthIndex = exports.fixLunarDate = exports.fixEarthlyBranchIndex = exports.getMutagensByHeavenlyStem = exports.getMutagen = exports.getBrightness = exports.earthlyBranchIndexToPalaceIndex = exports.fixIndex = void 0;
var lunar_lite_1 = require("lunar-lite");
exports.translateChineseDate = exports.getAgeIndex = exports.timeToIndex = exports.mergeStars = exports.fixLunarDayIndex = exports.fixLunarMonthIndex = exports.fixEarthlyBranchIndex = exports.getMutagensByHeavenlyStem = exports.getMutagen = exports.getBrightness = exports.earthlyBranchIndexToPalaceIndex = exports.fixIndex = void 0;
var data_1 = require("../data");
var star_1 = require("../star");
var i18n_1 = require("../i18n");
var dayjs_1 = __importDefault(require("dayjs"));
var lunar_lite_1 = require("lunar-lite");
/**

@@ -78,22 +74,2 @@ * 用于处理索引,将索引锁定在 0~max 范围内

/**
* 处理晚子时日期
*
* @param {string} solarDateStr 阳历日期
* @param {number} numbertimeIndex 时辰序号【0~12】,12代表晚子时
* @returns {LunarDate} LunarDate
*/
var fixLunarDate = function (solarDateStr, timeIndex) {
var lunarDate = (0, lunar_lite_1.solar2lunar)(solarDateStr);
// 获取当月的天数
var totalDaysOfLunarMonth = (0, lunar_lite_1.getTotalDaysOfLunarMonth)(lunarDate.lunarYear, lunarDate.lunarMonth);
if (timeIndex >= 12 && lunarDate.lunarDay >= totalDaysOfLunarMonth) {
// 假如是晚子时并且日期是农历月的最后一天时,月份需要加1
var dt = (0, dayjs_1.default)(solarDateStr);
dt.add(1, 'day');
lunarDate = (0, lunar_lite_1.solar2lunar)(new Date(dt.format()));
}
return lunarDate;
};
exports.fixLunarDate = fixLunarDate;
/**
* 调整农历月份的索引

@@ -112,7 +88,7 @@ *

var fixLunarMonthIndex = function (solarDateStr, timeIndex, fixLeap) {
var lunarDate = (0, exports.fixLunarDate)(solarDateStr, timeIndex);
var lunarMonth = lunarDate.lunarMonth, lunarDay = lunarDate.lunarDay, isLeap = lunarDate.isLeap;
var _a = (0, lunar_lite_1.solar2lunar)(solarDateStr), lunarMonth = _a.lunarMonth, lunarDay = _a.lunarDay, isLeap = _a.isLeap;
// 紫微斗数以`寅`宫为第一个宫位
var firstIndex = data_1.EARTHLY_BRANCHES.indexOf('yinEarthly');
return (0, exports.fixIndex)(lunarMonth + 1 - firstIndex + (isLeap && fixLeap && lunarDay > 15 ? 1 : 0));
var needToAdd = isLeap && fixLeap && lunarDay > 15 && timeIndex !== 12;
return (0, exports.fixIndex)(lunarMonth + 1 - firstIndex + (needToAdd ? 1 : 0));
};

@@ -119,0 +95,0 @@ exports.fixLunarMonthIndex = fixLunarMonthIndex;

{
"name": "iztro",
"version": "2.2.1",
"version": "2.2.2",
"description": "轻量级紫微斗数星盘生成库。可以通过出生年月日获取到紫微斗数星盘信息、生肖、星座等信息。A lightweight kit to astrolabe generator of The Purple Star Astrology (Zi Wei Dou Shu). The Purple Star Astrology(Zi Wei Dou Shu) is a Chinese ancient astrology. You're able to get your horoscope and personality from the astrolabe",

@@ -74,4 +74,4 @@ "main": "lib/index.js",

"i18next": "^23.5.1",
"lunar-lite": "^0.0.3"
"lunar-lite": "^0.1.1"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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