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 1.0.0 to 1.1.0

lib/data/types/astro.d.ts

28

CHANGELOG.md
# 紫微斗数 @sylarlong/astro
## v1.1.0
- 🪄 功能(feature)
🇨🇳
- 实现三方四正宫位功能 #21
🇺🇸
- implement surrounded palaces feature #21
- ✨ 改进(enhancement)
🇨🇳
- 支持性别国际化
- 将`timely`修改为`hourly`
- 优化`types`结构,将`types.ts`拆分进`types`文件夹内,方便维护
🇺🇸
- localization for gender
- rename `timely` to `hourly`
- optimize the structure of `types`: split `types.ts` into several parts and store them into `types` directory.
## v1.0.0

@@ -91,3 +117,3 @@

- implement timely horoscope #3
- implement hourly horoscope #3

@@ -94,0 +120,0 @@ - ✨ 改进(enhancement)

@@ -0,1 +1,2 @@

import { SurroundedPalaces } from '../data/types';
import { PalaceName, StarName } from '../i18n';

@@ -5,2 +6,12 @@ import { IFunctionalAstrolabe } from './FunctionalAstrolabe';

/**
* 获取三方四正宫位,所谓三方四正就是传入的目标宫位,以及其对宫,财帛位和官禄位,总共四个宫位
*
* @version v1.1.0
*
* @param $ 星盘实例
* @param indexOrName 宫位索引或者宫位名称
* @returns 三方四正宫位
*/
export declare const getSurroundedPalaces: ($: IFunctionalAstrolabe, indexOrName: number | PalaceName) => SurroundedPalaces;
/**
* 获取星盘的某一个宫位

@@ -54,1 +65,23 @@ *

export declare const isSurroundedByStars: ($: IFunctionalAstrolabe, indexOrName: number | PalaceName, stars: StarName[]) => boolean;
/**
* 判断三方四正内是否有传入星耀的其中一个,只要命中一个就会返回true
*
* @version v1.1.0
*
* @param $ 星盘实例
* @param indexOrName 宫位索引或者宫位名称
* @param stars 星耀名称数组
* @returns true | false
*/
export declare const isSurroundedByOneOfStars: ($: IFunctionalAstrolabe, indexOrName: number | PalaceName, stars: StarName[]) => boolean;
/**
* 判断某一个宫位三方四正是否不含目标星耀,必须要全部都不在三方四正内含才会返回true
*
* @version v1.1.0
*
* @param $ 星盘实例
* @param indexOrName 宫位索引或者宫位名称
* @param stars 星耀名称数组
* @returns true | false
*/
export declare const notSurroundedByStars: ($: IFunctionalAstrolabe, indexOrName: number | PalaceName, stars: StarName[]) => boolean;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.isSurroundedByStars = exports.hasOneOfStars = exports.notHaveStars = exports.hasStars = exports.getPalace = void 0;
exports.notSurroundedByStars = exports.isSurroundedByOneOfStars = exports.isSurroundedByStars = exports.hasOneOfStars = exports.notHaveStars = exports.hasStars = exports.getPalace = exports.getSurroundedPalaces = void 0;
var i18n_1 = require("../i18n");

@@ -39,3 +39,41 @@ var utils_1 = require("../utils");

};
var _getAllStarsInSurroundedPalaces = function (_a) {
var target = _a.target, opposite = _a.opposite, wealth = _a.wealth, career = _a.career;
return _concatStars(target.majorStars, target.minorStars, target.adjectiveStars, opposite.majorStars, opposite.minorStars, opposite.adjectiveStars, wealth.majorStars, wealth.minorStars, wealth.adjectiveStars, career.majorStars, career.minorStars, career.adjectiveStars);
};
/**
* 获取三方四正宫位,所谓三方四正就是传入的目标宫位,以及其对宫,财帛位和官禄位,总共四个宫位
*
* @version v1.1.0
*
* @param $ 星盘实例
* @param indexOrName 宫位索引或者宫位名称
* @returns 三方四正宫位
*/
var getSurroundedPalaces = function ($, indexOrName) {
// 获取目标宫位
var palace = (0, exports.getPalace)($, indexOrName);
if (!palace) {
throw new Error('indexOrName is inccorrect.');
}
// 获取目标宫位索引
var palaceIndex = (0, utils_1.fixEarthlyBranchIndex)(palace.earthlyBranch);
// 获取对宫
var palace6 = (0, exports.getPalace)($, (0, utils_1.fixIndex)(palaceIndex + 6));
// 官禄位
var palace4 = (0, exports.getPalace)($, (0, utils_1.fixIndex)(palaceIndex + 4));
// 财帛位
var palace8 = (0, exports.getPalace)($, (0, utils_1.fixIndex)(palaceIndex + 8));
if (!palace4 || !palace6 || !palace8) {
throw new Error('indexOrName is inccorrect.');
}
return {
target: palace,
wealth: palace8,
opposite: palace6,
career: palace4,
};
};
exports.getSurroundedPalaces = getSurroundedPalaces;
/**
* 获取星盘的某一个宫位

@@ -120,20 +158,38 @@ *

var isSurroundedByStars = function ($, indexOrName, stars) {
// 获取目标宫位
var palace = (0, exports.getPalace)($, indexOrName);
if (!palace) {
return false;
}
// 获取目标宫位索引
var palaceIndex = (0, utils_1.fixEarthlyBranchIndex)(palace.earthlyBranch);
// 获取对宫
var palace6 = (0, exports.getPalace)($, (0, utils_1.fixIndex)(palaceIndex + 6));
// 获取三方宫位
var palace4 = (0, exports.getPalace)($, (0, utils_1.fixIndex)(palaceIndex + 4));
var palace8 = (0, exports.getPalace)($, (0, utils_1.fixIndex)(palaceIndex + 8));
if (!palace4 || !palace6 || !palace8) {
return false;
}
var allStarsInPalace = _concatStars(palace.majorStars, palace.minorStars, palace.adjectiveStars, palace4.majorStars, palace4.minorStars, palace4.adjectiveStars, palace6.majorStars, palace6.minorStars, palace6.adjectiveStars, palace8.majorStars, palace8.minorStars, palace8.adjectiveStars);
var surroundedPalaces = (0, exports.getSurroundedPalaces)($, indexOrName);
var allStarsInPalace = _getAllStarsInSurroundedPalaces(surroundedPalaces);
return _includeAll(allStarsInPalace, stars);
};
exports.isSurroundedByStars = isSurroundedByStars;
/**
* 判断三方四正内是否有传入星耀的其中一个,只要命中一个就会返回true
*
* @version v1.1.0
*
* @param $ 星盘实例
* @param indexOrName 宫位索引或者宫位名称
* @param stars 星耀名称数组
* @returns true | false
*/
var isSurroundedByOneOfStars = function ($, indexOrName, stars) {
var surroundedPalaces = (0, exports.getSurroundedPalaces)($, indexOrName);
var allStarsInPalace = _getAllStarsInSurroundedPalaces(surroundedPalaces);
return _includeOneOf(allStarsInPalace, stars);
};
exports.isSurroundedByOneOfStars = isSurroundedByOneOfStars;
/**
* 判断某一个宫位三方四正是否不含目标星耀,必须要全部都不在三方四正内含才会返回true
*
* @version v1.1.0
*
* @param $ 星盘实例
* @param indexOrName 宫位索引或者宫位名称
* @param stars 星耀名称数组
* @returns true | false
*/
var notSurroundedByStars = function ($, indexOrName, stars) {
var surroundedPalaces = (0, exports.getSurroundedPalaces)($, indexOrName);
var allStarsInPalace = _getAllStarsInSurroundedPalaces(surroundedPalaces);
return _excludeAll(allStarsInPalace, stars);
};
exports.notSurroundedByStars = notSurroundedByStars;

7

lib/astro/astro.d.ts

@@ -1,2 +0,3 @@

import { Gender, Language } from '../data/types';
import { Language } from '../data/types';
import { GenderName } from '../i18n';
import FunctionalAstrolabe from './FunctionalAstrolabe';

@@ -12,3 +13,3 @@ /**

*/
export declare const astrolabeBySolarDate: (solarDateStr: string, timeIndex: number, gender: Gender, fixLeap?: boolean, language?: Language) => FunctionalAstrolabe;
export declare const astrolabeBySolarDate: (solarDateStr: string, timeIndex: number, gender: GenderName, fixLeap?: boolean, language?: Language) => FunctionalAstrolabe;
/**

@@ -24,2 +25,2 @@ * 通过农历获取星盘信息

*/
export declare const astrolabeByLunarDate: (lunarDateStr: string, timeIndex: number, gender: Gender, isLeapMonth?: boolean, fixLeap?: boolean, language?: Language) => FunctionalAstrolabe;
export declare const astrolabeByLunarDate: (lunarDateStr: string, timeIndex: number, gender: GenderName, isLeapMonth?: boolean, fixLeap?: boolean, language?: Language) => FunctionalAstrolabe;

@@ -1,2 +0,2 @@

import { Astrolabe, Horoscope } from '../data/types';
import { Astrolabe, Horoscope, SurroundedPalaces } from '../data/types';
import { EarthlyBranchName, PalaceName, StarName } from '../i18n';

@@ -25,2 +25,11 @@ import { IFunctionalPalace } from './FunctionalPalace';

/**
* 获取三方四正宫位,所谓三方四正就是传入的目标宫位,以及其对宫,财帛位和官禄位,总共四个宫位
*
* @version v1.1.0
*
* @param indexOrName 宫位索引或者宫位名称
* @returns 三方四正宫位
*/
surroundedPalaces: (indexOrName: number | PalaceName) => SurroundedPalaces;
/**
* 判断某一个宫位三方四正是否包含目标星耀,必须要全部包含才会返回true

@@ -33,2 +42,22 @@ *

isSurrounded: (indexOrName: number | PalaceName, stars: StarName[]) => boolean;
/**
* 判断三方四正内是否有传入星耀的其中一个,只要命中一个就会返回true
*
* @version v1.1.0
*
* @param indexOrName 宫位索引或者宫位名称
* @param stars 星耀名称数组
* @returns true | false
*/
isSurroundedOneOf: (indexOrName: number | PalaceName, stars: StarName[]) => boolean;
/**
* 判断某一个宫位三方四正是否不含目标星耀,必须要全部都不在三方四正内含才会返回true
*
* @version v1.1.0
*
* @param indexOrName 宫位索引或者宫位名称
* @param stars 星耀名称数组
* @returns true | false
*/
notSurrounded: (indexOrName: number | PalaceName, stars: StarName[]) => boolean;
}

@@ -56,3 +85,6 @@ export default class FunctionalAstrolabe implements IFunctionalAstrolabe {

palace: (indexOrName: number | PalaceName) => IFunctionalPalace | undefined;
surroundedPalaces: (indexOrName: number | PalaceName) => SurroundedPalaces;
isSurrounded: (indexOrName: number | PalaceName, stars: StarName[]) => boolean;
isSurroundedOneOf: (indexOrName: number | PalaceName, stars: StarName[]) => boolean;
notSurrounded: (indexOrName: number | PalaceName, stars: StarName[]) => boolean;
}

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

var convertTimeIndex = (0, utils_1.timeToIndex)(new Date(targetDate).getHours());
var _a = (0, calendar_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(targetDate.toString(), timeIndex || convertTimeIndex), yearly = _a.yearly, monthly = _a.monthly, daily = _a.daily, timely = _a.timely;
var _a = (0, calendar_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(targetDate.toString(), timeIndex || convertTimeIndex), yearly = _a.yearly, monthly = _a.monthly, daily = _a.daily, hourly = _a.hourly;
// 虚岁

@@ -53,3 +53,3 @@ var nominalAge = _date.lunarYear - _birthday.lunarYear;

// 流时索引
var timelyIndex = -1;
var hourlyIndex = -1;
// 查询大限索引

@@ -76,3 +76,3 @@ $.palaces.some(function (_a, index) {

data_1.EARTHLY_BRANCHES.indexOf((0, i18n_1.kot)($.rawDates.chineseDate.monthly[1])) +
data_1.EARTHLY_BRANCHES.indexOf((0, i18n_1.kot)($.rawDates.chineseDate.timely[1])) +
data_1.EARTHLY_BRANCHES.indexOf((0, i18n_1.kot)($.rawDates.chineseDate.hourly[1])) +
data_1.EARTHLY_BRANCHES.indexOf((0, i18n_1.kot)(monthly[1])));

@@ -82,3 +82,3 @@ // 获取流日索引

// 获取流时索引
timelyIndex = (0, utils_1.fixIndex)(dailyIndex + data_1.EARTHLY_BRANCHES.indexOf((0, i18n_1.kot)(timely[1])));
hourlyIndex = (0, utils_1.fixIndex)(dailyIndex + data_1.EARTHLY_BRANCHES.indexOf((0, i18n_1.kot)(hourly[1])));
var scope = {

@@ -121,8 +121,8 @@ solarDate: (0, calendar_1.normalizeSolarDateStr)(targetDate).join('-'),

},
timely: {
index: timelyIndex,
heavenlyStem: timely[0],
earthlyBranch: timely[1],
palaceNames: (0, palace_1.getPalaceNames)(timelyIndex),
mutagen: (0, utils_1.getMutagensByHeavenlyStem)(timely[0]),
hourly: {
index: hourlyIndex,
heavenlyStem: hourly[0],
earthlyBranch: hourly[1],
palaceNames: (0, palace_1.getPalaceNames)(hourlyIndex),
mutagen: (0, utils_1.getMutagensByHeavenlyStem)(hourly[0]),
},

@@ -140,5 +140,12 @@ };

this.palace = function (indexOrName) { return (0, analyzer_1.getPalace)(_this, indexOrName); };
this.surroundedPalaces = function (indexOrName) { return (0, analyzer_1.getSurroundedPalaces)(_this, indexOrName); };
this.isSurrounded = function (indexOrName, stars) {
return (0, analyzer_1.isSurroundedByStars)(_this, indexOrName, stars);
};
this.isSurroundedOneOf = function (indexOrName, stars) {
return (0, analyzer_1.isSurroundedByOneOfStars)(_this, indexOrName, stars);
};
this.notSurrounded = function (indexOrName, stars) {
return (0, analyzer_1.notSurroundedByStars)(_this, indexOrName, stars);
};
this.solarDate = data.solarDate;

@@ -145,0 +152,0 @@ this.lunarDate = data.lunarDate;

@@ -1,3 +0,3 @@

import { SoulAndBody, Decadal, Gender } from '../data/types';
import { EarthlyBranchName, FiveElementsClassName, HeavenlyStemName, PalaceName } from '../i18n';
import { SoulAndBody, Decadal } from '../data/types';
import { EarthlyBranchName, FiveElementsClassName, HeavenlyStemName, PalaceName, GenderName } from '../i18n';
/**

@@ -84,5 +84,5 @@ * 获取命宫以及身宫数据

*/
export declare const getHoroscope: (solarDateStr: string, timeIndex: number, gender: Gender, fixLeap?: boolean) => {
export declare const getHoroscope: (solarDateStr: string, timeIndex: number, gender: GenderName, fixLeap?: boolean) => {
decadals: Decadal[];
ages: number[][];
};

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

var data_1 = require("../data");
var types_1 = require("../data/types");
var i18n_1 = require("../i18n");

@@ -28,4 +27,4 @@ var utils_1 = require("../utils");

var getSoulAndBody = function (solarDate, timeIndex, fixLeap) {
var _a = (0, calendar_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(solarDate, timeIndex), yearly = _a.yearly, timely = _a.timely;
var earthlyBranchOfTime = (0, i18n_1.kot)(timely[1]);
var _a = (0, calendar_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(solarDate, timeIndex), yearly = _a.yearly, hourly = _a.hourly;
var earthlyBranchOfTime = (0, i18n_1.kot)(hourly[1]);
var heavenlyStemOfYear = (0, i18n_1.kot)(yearly[0]);

@@ -143,2 +142,3 @@ // 紫微斗数以`寅`宫为第一个宫位

var decadals = [];
var genderKey = (0, i18n_1.kot)(gender);
var yearly = (0, calendar_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(solarDateStr, timeIndex).yearly;

@@ -152,4 +152,4 @@ var heavenlyStem = (0, i18n_1.kot)(yearly[0]);

for (var i = 0; i < 12; i++) {
var idx = data_1.GENDER[gender] === data_1.earthlyBranches[earthlyBranch].yinYang ? (0, utils_1.fixIndex)(soulIndex + i) : (0, utils_1.fixIndex)(soulIndex - i);
var start = types_1.FiveElementsClass[fiveElementsClass] + 10 * i;
var idx = data_1.GENDER[genderKey] === data_1.earthlyBranches[earthlyBranch].yinYang ? (0, utils_1.fixIndex)(soulIndex + i) : (0, utils_1.fixIndex)(soulIndex - i);
var start = data_1.FiveElementsClass[fiveElementsClass] + 10 * i;
var heavenlyStemIndex = (0, utils_1.fixIndex)(data_1.HEAVENLY_STEMS.indexOf(startHeavenlyStem) + idx, 10);

@@ -156,0 +156,0 @@ var earthlyBranchIndex = (0, utils_1.fixIndex)(data_1.EARTHLY_BRANCHES.indexOf('yinEarthly') + idx);

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

var daily = (0, exports.heavenlyStemAndEarthlyBranchOfDay)(solarDate, timeIndex);
var timely = (0, exports.heavenlyStemAndEarthlyBranchOfTime)(timeIndex, daily[0]);
var hourly = (0, exports.heavenlyStemAndEarthlyBranchOfTime)(timeIndex, daily[0]);
return {

@@ -102,5 +102,5 @@ yearly: yearly,

daily: daily,
timely: timely,
hourly: hourly,
toString: function () {
return "".concat(yearly.join(''), " ").concat(monthly.join(''), " ").concat(daily.join(''), " ").concat(timely.join(''));
return "".concat(yearly.join(''), " ").concat(monthly.join(''), " ").concat(daily.join(''), " ").concat(hourly.join(''));
},

@@ -123,3 +123,3 @@ };

var daily = (0, exports.heavenlyStemAndEarthlyBranchOfDay)(solarDate, timeIndex);
var timely = (0, exports.heavenlyStemAndEarthlyBranchOfTime)(timeIndex, daily[0]);
var hourly = (0, exports.heavenlyStemAndEarthlyBranchOfTime)(timeIndex, daily[0]);
return {

@@ -129,5 +129,5 @@ yearly: yearly,

daily: daily,
timely: timely,
hourly: hourly,
toString: function () {
return "".concat(yearly.join(''), " ").concat(monthly.join(''), " ").concat(daily.join(''), " ").concat(timely.join(''));
return "".concat(yearly.join(''), " ").concat(monthly.join(''), " ").concat(daily.join(''), " ").concat(hourly.join(''));
},

@@ -134,0 +134,0 @@ };

@@ -13,6 +13,25 @@ /** 支持的语言 */

export declare const GENDER: {
readonly 男: "阳";
readonly 女: "阴";
readonly male: "阳";
readonly female: "阴";
};
/**
* 五行局,用于定紫微星和算起运年龄
* 几局就从几岁(虚岁)开始起运
* 比如 木三局 就从3岁开始起运
*
* @enum
* - 2 水二局
* - 3 木三局
* - 4 金四局
* - 5 土五局
* - 6 火六局
*/
export declare enum FiveElementsClass {
water2nd = 2,
wood3rd = 3,
metal4th = 4,
earth5th = 5,
fire6th = 6
}
/**
* 时辰, 子时分早晚。

@@ -19,0 +38,0 @@ * 其中 00:00-01:00 为早子时,23:00-00:00 为晚子时

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RAT_RULE = exports.TIGER_RULE = exports.TIME_RANGE = exports.CHINESE_TIME = exports.GENDER = exports.PALACES = exports.ZODIAC = exports.EARTHLY_BRANCHES = exports.HEAVENLY_STEMS = exports.LANGUAGES = void 0;
exports.RAT_RULE = exports.TIGER_RULE = exports.TIME_RANGE = exports.CHINESE_TIME = exports.FiveElementsClass = exports.GENDER = exports.PALACES = exports.ZODIAC = exports.EARTHLY_BRANCHES = exports.HEAVENLY_STEMS = exports.LANGUAGES = void 0;
/** 支持的语言 */

@@ -66,6 +66,26 @@ exports.LANGUAGES = ['en-US', 'ja-JP', 'ko-KR', 'zh-CN', 'zh-TW'];

exports.GENDER = {
男: '阳',
女: '阴',
male: '阳',
female: '阴',
};
/**
* 五行局,用于定紫微星和算起运年龄
* 几局就从几岁(虚岁)开始起运
* 比如 木三局 就从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 = {}));
/**
* 时辰, 子时分早晚。

@@ -72,0 +92,0 @@ * 其中 00:00-01:00 为早子时,23:00-00:00 为晚子时

@@ -37,2 +37,7 @@ import i18next from 'i18next';

import starZhTW from './locales/zh-TW/star';
import genderEnUS from './locales/en-US/gender';
import genderJaJP from './locales/ja-JP/gender';
import genderKoKR from './locales/ko-KR/gender';
import genderZhCN from './locales/zh-CN/gender';
import genderZhTW from './locales/zh-TW/gender';
import { Language } from '../data/types';

@@ -88,2 +93,9 @@ type StarEnUS = (typeof starEnUS)[keyof typeof starEnUS];

export type FiveElementsClassKey = keyof typeof fiveElementsClassZhCN;
type GenderEnUS = (typeof genderEnUS)[keyof typeof genderEnUS];
type GenderJaJP = (typeof genderJaJP)[keyof typeof genderJaJP];
type GenderKoKR = (typeof genderKoKR)[keyof typeof genderKoKR];
type GenderZhCN = (typeof genderZhCN)[keyof typeof genderZhCN];
type GenderZhTW = (typeof genderZhTW)[keyof typeof genderZhTW];
export type GenderName = GenderEnUS | GenderJaJP | GenderKoKR | GenderZhCN | GenderZhTW;
export type GenderKey = keyof typeof genderZhCN;
/**

@@ -90,0 +102,0 @@ * 设置国际化语言。

@@ -59,17 +59,22 @@ "use strict";

var star_5 = __importDefault(require("./locales/zh-TW/star"));
var gender_1 = __importDefault(require("./locales/en-US/gender"));
var gender_2 = __importDefault(require("./locales/ja-JP/gender"));
var gender_3 = __importDefault(require("./locales/ko-KR/gender"));
var gender_4 = __importDefault(require("./locales/zh-CN/gender"));
var gender_5 = __importDefault(require("./locales/zh-TW/gender"));
var resources = {
'en-US': {
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_1.default), fiveElementsClass_1.default), heavenlyStem_1.default), earthlyBranch_1.default), brightness_1.default), mutagen_1.default), star_1.default), palace_1.default),
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_1.default), fiveElementsClass_1.default), heavenlyStem_1.default), earthlyBranch_1.default), brightness_1.default), mutagen_1.default), star_1.default), palace_1.default), gender_1.default),
},
'ja-JP': {
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_2.default), fiveElementsClass_2.default), heavenlyStem_2.default), earthlyBranch_2.default), brightness_2.default), mutagen_2.default), star_2.default), palace_2.default),
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_2.default), fiveElementsClass_2.default), heavenlyStem_2.default), earthlyBranch_2.default), brightness_2.default), mutagen_2.default), star_2.default), palace_2.default), gender_2.default),
},
'ko-KR': {
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_3.default), fiveElementsClass_3.default), heavenlyStem_3.default), earthlyBranch_3.default), brightness_3.default), mutagen_3.default), star_3.default), palace_3.default),
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_3.default), fiveElementsClass_3.default), heavenlyStem_3.default), earthlyBranch_3.default), brightness_3.default), mutagen_3.default), star_3.default), palace_3.default), gender_3.default),
},
'zh-CN': {
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_4.default), fiveElementsClass_4.default), heavenlyStem_4.default), earthlyBranch_4.default), brightness_4.default), mutagen_4.default), star_4.default), palace_4.default),
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_4.default), fiveElementsClass_4.default), heavenlyStem_4.default), earthlyBranch_4.default), brightness_4.default), mutagen_4.default), star_4.default), palace_4.default), gender_4.default),
},
'zh-TW': {
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_5.default), fiveElementsClass_5.default), heavenlyStem_5.default), earthlyBranch_5.default), brightness_5.default), mutagen_5.default), star_5.default), palace_5.default),
translation: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, common_json_5.default), fiveElementsClass_5.default), heavenlyStem_5.default), earthlyBranch_5.default), brightness_5.default), mutagen_5.default), star_5.default), palace_5.default), gender_5.default),
},

@@ -76,0 +81,0 @@ };

{
"男": "male",
"女": "female",
"命主": "soul lord",
"身主": "body lord",
"rat": "rat",

@@ -7,0 +3,0 @@ "ox": "ox",

{
"男": "男性",
"女": "女性",
"命主": "命の主",
"身主": "身の主",
"rat": "鼠",

@@ -7,0 +3,0 @@ "ox": "牛",

{
"男": "남성",
"女": "여자",
"命主": "명주",
"身主": "신주",
"rat": "쥐",

@@ -7,0 +3,0 @@ "ox": "소",

{
"男": "男",
"女": "女",
"命主": "命主",
"身主": "身主",
"rat": "鼠",

@@ -7,0 +3,0 @@ "ox": "牛",

{
"男": "男",
"女": "女",
"命主": "命主",
"身主": "身主",
"rat": "鼠",

@@ -7,0 +3,0 @@ "ox": "牛",

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

var data_1 = require("../data");
var types_1 = require("../data/types");
var i18n_1 = require("../i18n");

@@ -49,4 +48,4 @@ var utils_1 = require("../utils");

var divisor = _day + offset;
quotient = Math.floor(divisor / types_1.FiveElementsClass[fiveElements]);
remainder = divisor % types_1.FiveElementsClass[fiveElements];
quotient = Math.floor(divisor / data_1.FiveElementsClass[fiveElements]);
remainder = divisor % data_1.FiveElementsClass[fiveElements];
} while (remainder !== 0);

@@ -53,0 +52,0 @@ // 将商除以12取余数

@@ -1,3 +0,3 @@

import { Star, Gender } from '../data/types';
import { StarName, HeavenlyStemName, EarthlyBranchName, FiveElementsClassName } from '../i18n';
import { Star } from '../data/types';
import { StarName, HeavenlyStemName, EarthlyBranchName, FiveElementsClassName, GenderName } from '../i18n';
export declare const initStars: () => Star[][];

@@ -62,3 +62,3 @@ /**

*/
export declare const getchangsheng12: (solarDateStr: string, timeIndex: number, gender: Gender, fixLeap?: boolean) => StarName[];
export declare const getchangsheng12: (solarDateStr: string, timeIndex: number, gender: GenderName, fixLeap?: boolean) => StarName[];
/**

@@ -73,3 +73,3 @@ * 博士12神。

*/
export declare const getBoShi12: (solarDateStr: string, gender: Gender) => StarName[];
export declare const getBoShi12: (solarDateStr: string, gender: GenderName) => StarName[];
/**

@@ -76,0 +76,0 @@ * 安流年将前诸星(按流年地支起将星)

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

var data_1 = require("../data");
var types_1 = require("../data/types");
var i18n_1 = require("../i18n");

@@ -264,3 +263,3 @@ var utils_1 = require("../utils");

var startIdx = 0;
switch (types_1.FiveElementsClass[fiveElementClass]) {
switch (data_1.FiveElementsClass[fiveElementClass]) {
case 2: {

@@ -303,2 +302,3 @@ startIdx = (0, utils_1.fixEarthlyBranchIndex)('shen');

var changsheng12 = [];
var genderKey = (0, i18n_1.kot)(gender);
var yearly = (0, calendar_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(solarDateStr, 0).yearly;

@@ -316,3 +316,3 @@ var earthlyBranchNameOfYear = yearly[1];

var idx = 0;
if (data_1.GENDER[gender] === data_1.earthlyBranches[earthlyBranchOfYear].yinYang) {
if (data_1.GENDER[genderKey] === data_1.earthlyBranches[earthlyBranchOfYear].yinYang) {
idx = (0, utils_1.fixIndex)(i + startIdx);

@@ -338,2 +338,3 @@ }

var getBoShi12 = function (solarDateStr, gender) {
var genderKey = (0, i18n_1.kot)(gender);
var yearly = (0, calendar_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(solarDateStr, 0).yearly;

@@ -361,3 +362,3 @@ var heavenlyStemNameOfYear = yearly[0], earthlyBranchNameOfYear = yearly[1];

// 阳男阴女顺行,阴男阳女逆部
var idx = (0, utils_1.fixIndex)(data_1.GENDER[gender] === data_1.earthlyBranches[earthlyBranchOfYear].yinYang ? luIndex + i : luIndex - i);
var idx = (0, utils_1.fixIndex)(data_1.GENDER[genderKey] === data_1.earthlyBranches[earthlyBranchOfYear].yinYang ? luIndex + i : luIndex - i);
boshi12[idx] = (0, i18n_1.t)(stars[i]);

@@ -364,0 +365,0 @@ }

{
"name": "iztro",
"version": "1.0.0",
"version": "1.1.0",
"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",

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

<div align="center">
# IZTRO
# 📦 IZTRO

@@ -11,3 +11,3 @@ A lightweight astrolabe generator of The Purple Star Astrology(Zi Wei Dou Shu).

[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/SylarLong/iztro/Codecov.yaml)](https://github.com/SylarLong/iztro/actions) [![npm](https://img.shields.io/npm/v/%40sylarlong%2Fastro)](https://www.npmjs.com/package/iztro) [![GitHub top language](https://img.shields.io/github/languages/top/SylarLong/iztro)](https://github.com/search?q=repo%3ASylarLong%2Fastro++language%3ATypeScript&type=code) [![Codecov](https://img.shields.io/codecov/c/github/sylarlong/iztro)](https://app.codecov.io/gh/SylarLong/iztro/tree/main/src%2Fstar) [![npm](https://img.shields.io/npm/dw/%40sylarlong/iztro)](https://www.npmjs.com/package/iztro) [![Maintenance](https://img.shields.io/maintenance/yes/2023)](https://github.com/SylarLong/iztro)
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/SylarLong/iztro/Codecov.yaml)](https://github.com/SylarLong/iztro/actions) [![npm](https://img.shields.io/npm/v/iztro)](https://www.npmjs.com/package/iztro) [![GitHub top language](https://img.shields.io/github/languages/top/SylarLong/iztro)](https://github.com/search?q=repo%3ASylarLong%2Fiztro++language%3ATypeScript&type=code) [![Codecov](https://img.shields.io/codecov/c/github/sylarlong/iztro)](https://app.codecov.io/gh/SylarLong/iztro/tree/main/src%2Fstar) [![npm](https://img.shields.io/npm/dw/%40sylarlong/iztro)](https://www.npmjs.com/package/iztro) [![Maintenance](https://img.shields.io/maintenance/yes/2023)](https://github.com/SylarLong/iztro)
[![GitHub](https://img.shields.io/github/license/sylarlong/iztro)](https://www.npmjs.com/package/iztro) [![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/SylarLong/iztro)](https://www.npmjs.com/package/iztro) [![npm bundle size](https://img.shields.io/bundlephobia/min/%40sylarlong%2Fastro)](https://www.npmjs.com/package/iztro) [![GitHub issues](https://img.shields.io/github/issues/SylarLong/iztro)](https://github.com/SylarLong/iztro/issues)

@@ -22,25 +22,58 @@ [![GitHub package.json dynamic](https://img.shields.io/github/package-json/author/sylarlong/iztro)](https://github.com/SylarLong)

[简体中文](./README.md) 🔸 English
简体中文 🔸 [English](./README-en_US.md)
</div>
### 📢 Introduction
---
This framework is used to generate the astrolabe of The Purple Star Astrology(Zi Wei Dou Shu). We support Simplified Chinese, Tradional Chinese, English, Korean and Japenese for now. If you have any issue please feel free to create issues in [here](https://github.com/SylarLong/iztro/discussions). feel free to create issues in [here](https://github.com/SylarLong/iztro/issues) if you found any bugs. I'll appreciate your star.🍻
### Summary
### 🌰 Demo
It's used to obtain the data of `The Purple Star Astrology (Zi Wei Dou Shu)`.
- [Demo](https://a.14star.cn)
Feature list
- To obtain the astrology data by birthday (`Solar calendar` or `Lunar calendar`) and birth time (`Chinese hour`).
- basic information(`birthday`, `Chinese hour`, `sign`, `Chinese zodiac`, `body lord`, `soul lord` etc.)
- palace information(`name`, `heavenly stem` and `earthly branch`, `stars` etc.)
- star information(`brightness`, `mutagen` and `type`)
- horoscope information(`decadal`, `nominal age`, `yearly`, `monthly`, `daily`, `hourly`)
- mutagen
- get `mutagen` by `heavenly stem`
- get `surrounded palaces` by palace `index` or `name`
- check whether specific `stars` in a specific `palace`
- check whether specific `stars` in `surrounded palaces`
- multilingual input/output results
### Quick link
- [Document](https://docs.iztro.com)
- [Discussions](https://github.com/SylarLong/iztro/discussions)
- [Issues](https://github.com/SylarLong/iztro/issues)
### 🎲 How to use it?
### Installation
#### 🚀 Let's get started
you can choose any package manager to install `iztro`.
```
npm i iztro -S
```
- NPM
#### ❓ Usage
```
npm install iztro -S
```
- Yarn
```
yarn add iztro
```
- pnpm
```
pnpm install iztro -S
```
### Simple example
This is a very simple example to show how to use `iztro` to get the astrolabe data. please visit [develop document](https://docs.iztro.com) for details.
- ES6 Module

@@ -51,7 +84,7 @@

// generate astrolabe by solar date
const astrolabe = astro.astrolabeBySolarDate('2000-8-16', 2, '女', true, 'zh-CN');
// get astrolabe data by solar date
const astrolabe = astro.astrolabeBySolarDate('2000-8-16', 2, 'male', true, 'en-US');
// generate astrolabe by lunar date
const astrolabe = astro.astrolabeByLunarDate('2000-7-17', 2, '女', false, true, 'zh-CN');
// get astrolabe data by lunar date
const astrolabe = astro.astrolabeByLunarDate('2000-7-17', 2, 'male', false, true, 'en-US');
```

@@ -64,20 +97,26 @@

// generate astrolabe by solar date
var astrolabe = iztro.astro.astrolabeBySolarDate('2000-8-16', 2, '女', true, 'zh-CN');
// get astrolabe data by solar date
var astrolabe = iztro.astro.astrolabeBySolarDate('2000-8-16', 2, 'male', true, 'en-US');
// generate astrolabe by lunar date
var astrolabe = iztro.astro.astrolabeByLunarDate('2000-7-17', 2, '女', false, true, 'zh-CN');
// get astrolabe data by lunar date
var astrolabe = iztro.astro.astrolabeByLunarDate('2000-7-17', 2, 'male', false, true, 'en-US');
```
Please refer to [document](https://docs.iztro.com) for details.
### [CONTRIBUTING](https://github.com/SylarLong/iztro/blob/main/CONTRIBUTING.md)
#### ☕ Summary
If you're interested in `iztro` and wish to join us,it's very welcome. You can contribute by:
Buy me a coffe if it's useful for you.👍 [Paypal Me](https://PayPal.Me/sylarlong)
- create an issue [here](https://github.com/SylarLong/iztro/issues/new?assignees=SylarLong&labels=%E5%8A%9F%E8%83%BD%EF%BD%9Cfeature&projects=&template=new-feature.md&title=%7B%E6%A0%87%E9%A2%98%7D%EF%BD%9C%7Btitle%7D) if you have any good ideas or suggestions.
- report a bug [here](https://github.com/SylarLong/iztro/issues/new?assignees=SylarLong&labels=%E6%BC%8F%E6%B4%9E%EF%BD%9Cbug&projects=&template=bug-report.md&title=%7Bversion%7D%3A%7Bfunction%7D-) if you found any bugs.
- you can also `fork` this code to your repository and create PRs for your changes.
- also, you can contribute the `localization` files. please refer to [locales](https://github.com/SylarLong/iztro/tree/main/src/i18n/locales) and create the localization files for your lanuage.
- additionally, buy me a coffee is another great way to support me👍 [Paypal Me](https://PayPal.Me/sylarlong)
You can create the astrolabe below based on the response data above. `palaces` is used to fill the 12-Palace and other fields are used to fill the Center Palace.
### Summary
You can generate an astrolabe by using the returned data. Of course it's just an example. You can focus on astrolabe design or data analyzation. This program solves the most tedious work for you, so that you can put more energy on the things you need to pay attention to.
![demo](https://github.com/SylarLong/iztro/assets/6510425/d2108ed7-6794-418a-b0e5-872c71ba6e1d)
#### 📜 LICENSE
### [LICENSE](https://github.com/SylarLong/iztro/blob/main/LICENSE)

@@ -87,3 +126,1 @@ MIT License

Copyright &copy; 2023 Sylar Long
Please use this open-source code responsibly and refrain from using it for illegal purposes.
<div align="center">
# IZTRO
# 📦 IZTRO

@@ -11,3 +11,3 @@ 一套轻量级紫微斗数排盘工具库。

[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/SylarLong/iztro/Codecov.yaml)](https://github.com/SylarLong/iztro/actions) [![npm](https://img.shields.io/npm/v/%40sylarlong%2Fastro)](https://www.npmjs.com/package/iztro) [![GitHub top language](https://img.shields.io/github/languages/top/SylarLong/iztro)](https://github.com/search?q=repo%3ASylarLong%2Fastro++language%3ATypeScript&type=code) [![Codecov](https://img.shields.io/codecov/c/github/sylarlong/iztro)](https://app.codecov.io/gh/SylarLong/iztro/tree/main/src%2Fstar) [![npm](https://img.shields.io/npm/dw/%40sylarlong/iztro)](https://www.npmjs.com/package/iztro) [![Maintenance](https://img.shields.io/maintenance/yes/2023)](https://github.com/SylarLong/iztro)
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/SylarLong/iztro/Codecov.yaml)](https://github.com/SylarLong/iztro/actions) [![npm](https://img.shields.io/npm/v/iztro)](https://www.npmjs.com/package/iztro) [![GitHub top language](https://img.shields.io/github/languages/top/SylarLong/iztro)](https://github.com/search?q=repo%3ASylarLong%2Fiztro++language%3ATypeScript&type=code) [![Codecov](https://img.shields.io/codecov/c/github/sylarlong/iztro)](https://app.codecov.io/gh/SylarLong/iztro/tree/main/src%2Fstar) [![npm](https://img.shields.io/npm/dw/%40sylarlong/iztro)](https://www.npmjs.com/package/iztro) [![Maintenance](https://img.shields.io/maintenance/yes/2023)](https://github.com/SylarLong/iztro)
[![GitHub](https://img.shields.io/github/license/sylarlong/iztro)](https://www.npmjs.com/package/iztro) [![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/SylarLong/iztro)](https://www.npmjs.com/package/iztro) [![npm bundle size](https://img.shields.io/bundlephobia/min/%40sylarlong%2Fastro)](https://www.npmjs.com/package/iztro) [![GitHub issues](https://img.shields.io/github/issues/SylarLong/iztro)](https://github.com/SylarLong/iztro/issues)

@@ -26,21 +26,52 @@ [![GitHub package.json dynamic](https://img.shields.io/github/package-json/author/sylarlong/iztro)](https://github.com/SylarLong)

### 📢 介绍
---
用于紫微斗数排盘的工具库,目前支持简体中文、繁体中文、英文、韩文、日文,大家有任何问题欢迎到[这里](https://github.com/SylarLong/iztro/discussions)提问交流,如果发现程序有不对的地方,欢迎到[这里](https://github.com/SylarLong/iztro/issues)提交Bug。扣码不易,希望得到各位大佬的星星。🍻
### 介绍
### 🌰 举个栗子
用于紫微斗数排盘的javascript开源库,有以下功能。
- [Demo](https://a.14star.cn)
- [文档](https://docs.iztro.com)
- 根据出生日期(`农历`或`阳历`)以及出生时辰获取紫微斗数`星盘数据`,星盘数据包括
- 基础信息(出生日期,时辰,星座,生肖,身主,命主等信息)
- 宫位信息(宫位名称,干支,星耀等)
- 星耀信息(包括亮度【(庙、旺、得、利、平、不、陷)】,四化【禄,权,科,忌】和类型)
- 运限信息(大限,小限,流年,流月,流日,流时)
- 星耀四化
- 根据天干获取四化
- 查询指定宫位三方四正宫位
- 查询指定星耀是否存在指定宫位内
- 查询指定星耀是否存在于三方四正内
- 多语言输入/输出结果
### 🎲 用法
### 快捷跳转
#### 🚀 让我们开始把
- [开发文档](https://docs.iztro.com)
- [讨论](https://github.com/SylarLong/iztro/discussions)
- [问题](https://github.com/SylarLong/iztro/issues)
```
npm i iztro -S
```
### 安装依赖
#### ❓ 调用方法
你可以使用任何你熟悉的包管理库来安装`iztro`
- NPM
```
npm install iztro -S
```
- Yarn
```
yarn add iztro
```
- pnpm
```
pnpm install iztro -S
```
### 例子
这里是一个简单的例子显示如何调用`iztro`获取到紫微斗数星盘数据,详细文档请移步[开发文档](https://docs.iztro.com)
- ES6 Module

@@ -70,13 +101,19 @@

相信文档请移步[开发文档](https://docs.isztro.com)
### [贡献指南](https://github.com/SylarLong/iztro/blob/main/CONTRIBUTING.md)
#### ☕ 总结
如果你对`iztro`有兴趣,也想加入贡献队伍,我们非常欢迎,你可以用以下方式进行:
如果您觉得本程序对您有用的话,可以给我带杯咖啡吗?👍 [Paypal Me](https://PayPal.Me/sylarlong)
- 如果你对程序功能有什么建议,请到[这里](https://github.com/SylarLong/iztro/issues/new?assignees=SylarLong&labels=%E5%8A%9F%E8%83%BD%EF%BD%9Cfeature&projects=&template=new-feature.md&title=%7B%E6%A0%87%E9%A2%98%7D%EF%BD%9C%7Btitle%7D)创建一个`功能需求`。
- 如果你发现程序有BUG,请到[这里](https://github.com/SylarLong/iztro/issues/new?assignees=SylarLong&labels=%E6%BC%8F%E6%B4%9E%EF%BD%9Cbug&projects=&template=bug-report.md&title=%7Bversion%7D%3A%7Bfunction%7D-)创建一个`BUG报告`。
- 你也可以将本仓库`fork`到你自己的仓库进行编辑,然后提交PR到本仓库。
- 假如你擅长外语,我们也欢迎你对国际化文件的翻译做出你的贡献,你可以`fork`本仓库,然后在[locales](https://github.com/SylarLong/iztro/tree/main/src/i18n/locales)文件夹下创建一个国际化语言文件,然后复制其他语言文件目录里面的文件到你的目录下进行更改。
- 当然,如果在我挑灯码字的时候能的到你赞助的咖啡,在下也是不胜感激👍 [Paypal Me](https://PayPal.Me/sylarlong)
以上数据可以生成如下星盘,其中`palaces`数据用于填充12宫,其他数据用于填充中宫。
### 总结
使用本程序返回的数据,你可以生成这样一张星盘,当然这只是一个例子,你可以把注意力集中在星盘的设计上,也可以把重心放在数据的分析上,本程序为你解决了最繁冗的工作,让你可以把精力更多的放在你所需要关注的事情上面。
![demo](https://github.com/SylarLong/iztro/assets/6510425/d2108ed7-6794-418a-b0e5-872c71ba6e1d)
#### 📜 版权(LICENSE)
### [版权](https://github.com/SylarLong/iztro/blob/main/LICENSE)

@@ -83,0 +120,0 @@ MIT License

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