Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

iztro

Package Overview
Dependencies
Maintainers
1
Versions
55
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
1.2.6
to
1.2.7-alpha
+10
-0
CHANGELOG.md

@@ -12,2 +12,12 @@ # 紫微斗数 @sylarlong/astro

- 🪄 功能(features)
🇨🇳
- 在流年运限里返回流年神煞 #56
🇺🇸
- return yearly decorative stars #56
- 🛠️ 修复(fix)

@@ -14,0 +24,0 @@

+5
-1

@@ -11,3 +11,7 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var dayjs_1 = __importDefault(require("dayjs"));
var calendar_1 = require("../calendar");

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

var _date = (0, calendar_1.solar2lunar)(targetDate);
var convertTimeIndex = (0, utils_1.timeToIndex)(new Date(targetDate).getHours());
var convertTimeIndex = (0, utils_1.timeToIndex)((0, dayjs_1.default)(targetDate).hour());
var _a = (0, calendar_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(targetDate.toString(), timeIndex || convertTimeIndex), yearly = _a.yearly, monthly = _a.monthly, daily = _a.daily, hourly = _a.hourly;

@@ -39,0 +43,0 @@ // 虚岁

+7
-3
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.lunar2solar = exports.solar2lunar = exports.normalizeSolarDateStr = exports.normalizeLunarDateStr = void 0;
var dayjs_1 = __importDefault(require("dayjs"));
var days_1 = require("./days");

@@ -26,7 +30,7 @@ var leap_1 = require("./leap");

var normalizeSolarDateStr = function (dateStr) {
var date = new Date(dateStr);
if (date.toString() === 'Invalid Date') {
var date = (0, dayjs_1.default)(dateStr);
if (!date.isValid()) {
throw new Error('invalid date.');
}
return [date.getFullYear(), date.getMonth() + 1, date.getDate()];
return [date.year(), date.month() + 1, date.date()];
};

@@ -33,0 +37,0 @@ exports.normalizeSolarDateStr = normalizeSolarDateStr;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHeavenlyStemAndEarthlyBranchBySolarDate = exports.getHeavenlyStemAndEarthlyBranchByLunarDate = exports.heavenlyStemAndEarthlyBranchOfTime = exports.heavenlyStemAndEarthlyBranchOfDay = exports.heavenlyStemAndEarthlyBranchOfMonth = exports.heavenlyStemAndEarthlyBranchOfYear = void 0;
var dayjs_1 = __importDefault(require("dayjs"));
var data_1 = require("../data");

@@ -92,3 +96,3 @@ var i18n_1 = require("../i18n");

var solar = (0, convertor_1.lunar2solar)(dateStr, isLeap);
var solarDate = new Date(solar.toString());
var solarDate = new Date((0, dayjs_1.default)(solar.toString()).format());
var yearly = (0, exports.heavenlyStemAndEarthlyBranchOfYear)(lunarYear);

@@ -95,0 +99,0 @@ var monthly = (0, exports.heavenlyStemAndEarthlyBranchOfMonth)(solarDate);

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,2 +11,3 @@ 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 i18n_1 = require("../i18n");
var dayjs_1 = __importDefault(require("dayjs"));
/**

@@ -87,5 +91,5 @@ * 用于处理索引,将索引锁定在 0~max 范围内

// 假如是晚子时并且日期是农历月的最后一天时,月份需要加1
var dt = new Date(solarDateStr);
dt.setDate(dt.getDate() + 1);
lunarDate = (0, calendar_1.solar2lunar)(dt);
var dt = (0, dayjs_1.default)(solarDateStr);
dt.add(1, 'day');
lunarDate = (0, calendar_1.solar2lunar)(new Date(dt.format()));
}

@@ -92,0 +96,0 @@ return lunarDate;

{
"name": "iztro",
"version": "1.2.6",
"version": "1.2.7-alpha",
"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",

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

"dependencies": {
"dayjs": "^1.11.10",
"i18next": "^23.5.1"
}
}
import { CHINESE_TIME, LANGUAGES, TIME_RANGE } from './constants';
import { Brightness, EarthlyBranchName, FiveElementsClassName, HeavenlyStemName, Mutagen, PalaceName, StarName } from '../i18n';
import { IFunctionalPalace } from '../astro/FunctionalPalace';
/** 支持的语言 */
export type Language = (typeof LANGUAGES)[number];
/** 性别 */
export type Gender = '男' | '女';
/** 阴阳 */
export type YinYang = '阴' | '阳';
/** 五行 */
export type FiveElements = '木' | '金' | '水' | '火' | '土';
/** 时辰,子时分早晚 */
export type ChineseTime = (typeof CHINESE_TIME)[number];
/** 时辰对应的时间段 */
export type TimeRange = (typeof TIME_RANGE)[number];
/** 范围:本命|大限|流年 */
export type Scope = 'origin' | 'decadal' | 'yearly';
/** 星耀类型 */
export type StarType = 'major' | 'soft' | 'tough' | 'adjective' | 'flower' | 'helper' | 'lucun' | 'tianma';
/**
* 紫微斗数星耀
*
* @property
* - name 星耀名字
* - type 星耀类型
* - scope 作用范围
* - brightness 星耀亮度
* - mutagen 四化
*/
export type Star = {
/** 星耀名字 */
name: StarName;
/** 星耀类型(主星 | 吉星 | 煞星 | 杂耀 | 桃花星 | 解神 | 禄存 | 天马) */
type: StarType;
/** 作用范围(本命盘 | 大限盘 | 流年盘) */
scope: Scope;
/** 星耀亮度,若没有亮度数据则此字段为`空字符串`或者 `undefined` */
brightness?: Brightness;
/** 四化,若未产生四化则此字段为 `undefined` */
mutagen?: Mutagen;
};
/**
* 五行局,用于定紫微星和算起运年龄
* 几局就从几岁(虚岁)开始起运
* 比如 木三局 就从3岁开始起运
*
* @enum
* - 2 水二局
* - 3 木三局
* - 4 金四局
* - 5 土五局
* - 6 火六局
*/
export declare enum FiveElementsClass {
water2nd = 2,
wood3rd = 3,
metal4th = 4,
earth5th = 5,
fire6th = 6
}
/**
* 农历日期对象
*
* @property
* - lunarYear 年
* - lunarMonth 月
* - lunarDay 日
* - isLeap 月份是否闰月
*
* @function toString() 输出 YYYY-M-D 或 农历中文 字符串
*/
export type LunarDate = {
/** 农历年 */
lunarYear: number;
/** 农历月 */
lunarMonth: number;
/** 农历日 */
lunarDay: number;
/** 是否闰月 */
isLeap: boolean;
/**
* 转化为字符串
*
* @param toCnStr 是否使用中文字符串, 若该参数为false则字符串中不会携带闰月信息
* @returns string
* @example
* lunarYear = 2023;
* lunarMonth = 6;
* lunarDay = 12;
* isLeap = true;
*
* toString(); // 2023-6-12
* toString(true); // 二〇二三年(闰)二月十一
*/
toString: (toCnStr?: boolean) => string;
};
/**
* 阳历日期对象
*
* @property
* - solarYear 年
* - solarMonth 月
* - solarDay 日
*
* @function toString() 将对象以 YYYY-M-D 格式字符串输出
*/
export type SolarDate = {
/** 公历年 */
solarYear: number;
/** 公历月 */
solarMonth: number;
/** 公历日 */
solarDay: number;
/**
* 转化为字符串
*
* @returns string
* @example
* solarYear = 2023;
* solarMonth = 6;
* solarDay = 12;
*
* toString(); // 2023-6-12
*/
toString: () => string;
};
/** [天干,地支] */
export type HeavenlyStemAndEarthlyBranch = [HeavenlyStemName, EarthlyBranchName];
/**
* 干支纪年日期对象
*
* @property
* - yearly 年柱[天干,地支]
* - monthly 月柱[天干,地支]
* - monthly 月柱[天干,地支]
* - daily 日柱[天干,地支]
* - timely 时柱[天干,地支]
*
* @function toString() 将对象以干支纪年字符串输出
*/
export type HeavenlyStemAndEarthlyBranchDate = {
/** 年柱[天干,地支] */
yearly: HeavenlyStemAndEarthlyBranch;
/** 月柱[天干,地支] */
monthly: HeavenlyStemAndEarthlyBranch;
/** 日柱[天干,地支] */
daily: HeavenlyStemAndEarthlyBranch;
/** 时柱[天干,地支] */
timely: HeavenlyStemAndEarthlyBranch;
/**
* 获取四柱的字符串
*
* @returns 四柱字符串,用空格隔开
* @example
* yearly = ['癸', '卯'];
* monthly = ['戊', '午'];
* daily = ['癸', '亥'];
* timely = ['甲', '寅'];
* toString(); // 癸卯 戊午 癸亥 甲寅
*/
toString: () => string;
};
/**
* 命宫、身宫对象
*
* @property
* - soulIndex 命宫索引
* - bodyIndex 身宫索引
* - heavenlyStemOfSoul 命宫天干
* - earthlyBranchOfSoul 命宫地支
*/
export type SoulAndBody = {
/** 命宫索引 */
soulIndex: number;
/** 身宫索引 */
bodyIndex: number;
/** 命宫天干 */
heavenlyStemOfSoul: HeavenlyStemName;
/** 命宫地支 */
earthlyBranchOfSoul: EarthlyBranchName;
};
/**
* 大限
*
* @property
* - range 大限起止年龄 [起始年龄, 截止年龄]
* - heavenlyStem 大限天干
* - earthlyBranch 大限地支
*/
export type Decadal = {
/** 大限起止年龄 [起始年龄, 截止年龄] */
range: [number, number];
/** 大限天干 */
heavenlyStem: HeavenlyStemName;
/** 大限地支 */
earthlyBranch: EarthlyBranchName;
};
/**
* 宫位对象
*
* @property
* - name 宫位名称
* - isBodyPalace 是否身宫
* - isOriginalPalace 是否来因宫
* - heavenlyStem 宫位天干
* - earthlyBranch 宫位地支
* - majorStars 主星
* - minorStars 辅星
* - adjectiveStars 杂耀
* - changsheng12 长生12神之一
* - boshi12 博士12神之一
* - jiangqian12 将前12神之一
* - suiqian12 岁前12神之一
* - decadal 大限
* - ages 小限
*/
export type Palace = {
/** 宫位名称 */
name: PalaceName;
/** 是否身宫 */
isBodyPalace: boolean;
/** 是否来因宫 */
isOriginalPalace: boolean;
/** 宫位天干 */
heavenlyStem: HeavenlyStemName;
/** 宫位地支 */
earthlyBranch: EarthlyBranchName;
/** 主星 */
majorStars: Star[];
/** 辅星 */
minorStars: Star[];
/** 杂耀 */
adjectiveStars: Star[];
/** 长生12神 */
changsheng12: StarName;
/** 博士12神 */
boshi12: StarName;
/** 流年将前12神 */
jiangqian12: StarName;
/** 流年岁前12神 */
suiqian12: StarName;
/** 大限 */
decadal: Decadal;
/** 小限 */
ages: number[];
};
/**
* 运限对象
*
* @property
* - index 所在宫位的索引
* - heavenlyStem 该运限天干
* - palaceNames 该运限的十二宫
* - mutagen 四化星
* - stars 流耀
*/
export type HoroscopeItem = {
/** 所在宫位的索引 */
index: number;
/** 该运限天干 */
heavenlyStem: HeavenlyStemName;
/** 该运限地支 */
earthlyBranch: EarthlyBranchName;
/** 该运限的十二宫 */
palaceNames: PalaceName[];
/** 四化星 */
mutagen: StarName[];
/** 流耀 */
stars?: Star[][];
};
/**
* 运限
*
* @property
* - lunarDate 农历日期
* - solarDate 阳历日期
* - decadal 大限
* - age 小限
* - yearly 流年
* - monthly 流月
* - daily 流日
*/
export type Horoscope = {
/** 农历日期 */
lunarDate: string;
/** 阳历日期 */
solarDate: string;
/** 大限 */
decadal: HoroscopeItem;
/**
* 小限
*
* @property
* - index 小限所在宫位索引
* - nominalAge 虚岁
*/
age: {
/** 小限所在宫位索引 */
index: number;
/** 虚岁 */
nominalAge: number;
};
/** 流年 */
yearly: HoroscopeItem;
/** 流月 */
monthly: HoroscopeItem;
/** 流日 */
daily: HoroscopeItem;
/** 流时 */
timely: HoroscopeItem;
};
/**
* 星盘对象
*
* @property
* - solarDate 阳历日期
* - lunarDate 农历日期
* - chineseDate 干支纪年日期
* - time 时辰
* - timeRange 时辰对应的时间段
* - sign 星座
* - zodiac 生肖
* - earthlyBranchOfSoulPalace 命宫地支
* - earthlyBranchOfBodyPalace 身宫地支
* - soul 命主
* - body 身主
* - palaces 十二宫数据
*
* @function
* - horoscope() 获取运限数据
* - palace() 获取宫位数据
*/
export type Astrolabe = {
/** 阳历日期 */
solarDate: string;
/** 农历日期 */
lunarDate: string;
/** 干支纪年日期 */
chineseDate: string;
/**
* 原始日期数据,用于今后内部方法使用
*
* @property
* - lunar 农历日期对象
* - chinese 干支纪年日期对象
*/
rawDates: {
/** 农历日期对象 */
lunarDate: LunarDate;
/** 干支纪年日期对象 */
chineseDate: HeavenlyStemAndEarthlyBranchDate;
};
/** 时辰 */
time: ChineseTime;
/** 时辰对应的时间段 */
timeRange: TimeRange;
/** 星座 */
sign: string;
/** 生肖 */
zodiac: string;
/** 命宫地支 */
earthlyBranchOfSoulPalace: EarthlyBranchName;
/** 身宫地支 */
earthlyBranchOfBodyPalace: EarthlyBranchName;
/** 命主 */
soul: StarName;
/** 身主 */
body: StarName;
/** 五行局 */
fiveElementsClass: FiveElementsClassName;
/** 十二宫数据 */
palaces: IFunctionalPalace[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FiveElementsClass = void 0;
/**
* 五行局,用于定紫微星和算起运年龄
* 几局就从几岁(虚岁)开始起运
* 比如 木三局 就从3岁开始起运
*
* @enum
* - 2 水二局
* - 3 木三局
* - 4 金四局
* - 5 土五局
* - 6 火六局
*/
var FiveElementsClass;
(function (FiveElementsClass) {
FiveElementsClass[FiveElementsClass["water2nd"] = 2] = "water2nd";
FiveElementsClass[FiveElementsClass["wood3rd"] = 3] = "wood3rd";
FiveElementsClass[FiveElementsClass["metal4th"] = 4] = "metal4th";
FiveElementsClass[FiveElementsClass["earth5th"] = 5] = "earth5th";
FiveElementsClass[FiveElementsClass["fire6th"] = 6] = "fire6th";
})(FiveElementsClass || (exports.FiveElementsClass = FiveElementsClass = {}));