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.0.8 to 2.1.0

12

CHANGELOG.md

@@ -10,2 +10,14 @@ # 紫微斗数

## v2.1.0
- 🪄 功能(feature)
🇨🇳
- 宫位飞星判断 #143
🇺🇸
- flyinstar judgement feature #143
## v2.0.8

@@ -12,0 +24,0 @@

3

lib/astro/analyzer.d.ts

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

import { Mutagen, PalaceName, StarName } from '../i18n';
import { HeavenlyStemName, Mutagen, PalaceName, StarName } from '../i18n';
import { IFunctionalAstrolabe } from './FunctionalAstrolabe';

@@ -99,1 +99,2 @@ import { IFunctionalPalace } from './FunctionalPalace';

export declare const notSurroundedByStars: ($: IFunctionalSurpalaces, stars: StarName[]) => boolean;
export declare const mutagensToStars: (heavenlyStem: HeavenlyStemName, mutagens: Mutagen | Mutagen[]) => StarName[];

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

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

@@ -92,2 +93,3 @@ var utils_1 = require("../utils");

var getPalace = function ($, indexOrName) {
var palace;
if (typeof indexOrName === 'number') {

@@ -97,15 +99,19 @@ if (indexOrName < 0 || indexOrName > 11) {

}
return $.palaces[indexOrName];
palace = $.palaces[indexOrName];
}
return $.palaces.find(function (item) {
if ((0, i18n_1.kot)(indexOrName) === 'originalPalace' && item.isOriginalPalace) {
return item;
}
if ((0, i18n_1.kot)(indexOrName) === 'bodyPalace' && item.isBodyPalace) {
return item;
}
if ((0, i18n_1.kot)(item.name) === (0, i18n_1.kot)(indexOrName)) {
return item;
}
});
else {
palace = $.palaces.find(function (item) {
if ((0, i18n_1.kot)(indexOrName) === 'originalPalace' && item.isOriginalPalace) {
return item;
}
if ((0, i18n_1.kot)(indexOrName) === 'bodyPalace' && item.isBodyPalace) {
return item;
}
if ((0, i18n_1.kot)(item.name) === (0, i18n_1.kot)(indexOrName)) {
return item;
}
});
}
palace === null || palace === void 0 ? void 0 : palace.setAstrolabe($);
return palace;
};

@@ -218,1 +224,15 @@ exports.getPalace = getPalace;

exports.notSurroundedByStars = notSurroundedByStars;
var mutagensToStars = function (heavenlyStem, mutagens) {
var muts = Array.isArray(mutagens) ? mutagens : [mutagens];
var stars = [];
var mutagenStars = (0, utils_1.getMutagensByHeavenlyStem)(heavenlyStem);
muts.forEach(function (withMutagen) {
var mutagenIndex = data_1.MUTAGEN.indexOf((0, i18n_1.kot)(withMutagen));
if (!mutagenStars[mutagenIndex]) {
return;
}
stars.push(mutagenStars[mutagenIndex]);
});
return stars;
};
exports.mutagensToStars = mutagensToStars;

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

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

@@ -6,3 +6,3 @@ import { IFunctionalStar } from '../star/FunctionalStar';

import { IFunctionalSurpalaces } from './FunctionalSurpalaces';
import FunctionalHoroscope from './FunctionalHoroscope';
import { IFunctionalHoroscope } from './FunctionalHoroscope';
/**

@@ -23,3 +23,3 @@ * 星盘类接口定义。

*/
horoscope: (date?: string | Date, timeIndex?: number) => Horoscope;
horoscope: (date?: string | Date, timeIndex?: number) => IFunctionalHoroscope;
/**

@@ -112,3 +112,3 @@ * 通过星耀名称获取到当前星耀的对象实例

star: (starName: StarName) => IFunctionalStar;
horoscope: (targetDate?: string | Date, timeIndexOfTarget?: number) => FunctionalHoroscope;
horoscope: (targetDate?: string | Date, timeIndexOfTarget?: number) => IFunctionalHoroscope;
palace: (indexOrName: number | PalaceName) => IFunctionalPalace | undefined;

@@ -115,0 +115,0 @@ surroundedPalaces: (indexOrName: number | PalaceName) => IFunctionalSurpalaces;

import { Horoscope, Scope } from '../data/types';
import { Mutagen, PalaceName, StarName } from '../i18n';
import { IFunctionalAstrolabe } from './FunctionalAstrolabe';
import { FunctionalSurpalaces } from './FunctionalSurpalaces';
import FunctionalPalace from './FunctionalPalace';
import { IFunctionalSurpalaces } from './FunctionalSurpalaces';
import { IFunctionalPalace } from './FunctionalPalace';
export interface IFunctionalHoroscope extends Horoscope {
astrolabe: IFunctionalAstrolabe;
/**

@@ -12,5 +13,5 @@ * 获取小限宫位

*
* @returns {FunctionalPalace | undefined} 小限宫位
* @returns {IFunctionalPalace | undefined} 小限宫位
*/
agePalace: () => FunctionalPalace | undefined;
agePalace: () => IFunctionalPalace | undefined;
/**

@@ -23,5 +24,5 @@ * 获取运限宫位

* @param scope 指定获取哪个运限的宫位
* @returns {FunctionalPalace | undefined} 指定宫位
* @returns {IFunctionalPalace | undefined} 指定宫位
*/
palace: (palaceName: PalaceName, scope: Scope) => FunctionalPalace | undefined;
palace: (palaceName: PalaceName, scope: Scope) => IFunctionalPalace | undefined;
/**

@@ -34,5 +35,5 @@ * 获取运限指定宫位的三方四正宫位

* @param scope 指定获取哪个运限的宫位
* @returns {FunctionalSurpalaces | undefined} 指定宫位的三方四正
* @returns {IFunctionalSurpalaces | undefined} 指定宫位的三方四正
*/
surroundPalaces: (palaceName: PalaceName, scope: Scope) => FunctionalSurpalaces | undefined;
surroundPalaces: (palaceName: PalaceName, scope: Scope) => IFunctionalSurpalaces | undefined;
/**

@@ -103,5 +104,5 @@ * 判断在指定运限的宫位内是否包含流耀,需要全部包含才返回true

constructor(data: Horoscope, astrolabe: IFunctionalAstrolabe);
agePalace: () => import("./FunctionalPalace").IFunctionalPalace | undefined;
palace: (palaceName: PalaceName, scope: Scope) => import("./FunctionalPalace").IFunctionalPalace | undefined;
surroundPalaces: (palaceName: PalaceName, scope: Scope) => import("./FunctionalSurpalaces").IFunctionalSurpalaces;
agePalace: () => IFunctionalPalace | undefined;
palace: (palaceName: PalaceName, scope: Scope) => IFunctionalPalace | undefined;
surroundPalaces: (palaceName: PalaceName, scope: Scope) => IFunctionalSurpalaces;
hasHoroscopeStars: (palaceName: PalaceName, scope: Scope, horoscopeStar: StarName[]) => boolean;

@@ -108,0 +109,0 @@ notHaveHoroscopeStars: (palaceName: PalaceName, scope: Scope, horoscopeStar: StarName[]) => boolean;

import { Palace } from '../data/types';
import { Mutagen, StarName } from '../i18n';
import { Mutagen, PalaceName, StarName } from '../i18n';
import { IFunctionalAstrolabe } from './FunctionalAstrolabe';
/**

@@ -67,2 +68,85 @@ * 宫位类的接口定义。

isEmpty: (excludeStars?: StarName[]) => boolean;
/**
* 给宫位设置星盘对象
*
* @version v2.1.0
*
* @param astro 星盘对象
* @returns {void}
*/
setAstrolabe: (astro: IFunctionalAstrolabe) => void;
/**
* 获取当前宫位所在的星盘对象
*
* @version v2.1.0
*
* @returns {IFunctionalAstrolabe}
*/
astrolabe: () => IFunctionalAstrolabe | undefined;
/**
* 判断是否从源宫位飞化到目标宫位,四化可传入一个数组或者一个字符串,传入四化全部飞化到目标宫位即返回true
*
* @version v2.1.0
*
* @param from 源宫位
* @param to 目标宫位
* @param withMutagens 四化(禄、权、科、忌)
* @returns {boolean}
*/
fliesTo: (to: number | PalaceName, withMutagens: Mutagen | Mutagen[]) => boolean;
/**
* 判断是否从源宫位飞化其中一颗四化星到目标宫位,传入四化只要有一颗飞化到目标宫位即返回true
*
* @version v2.1.0
*
* @param to 目标宫位
* @param withMutagens 四化(禄、权、科、忌)
* @returns {boolean}
*/
fliesOneOfTo: (to: number | PalaceName, withMutagens: Mutagen[]) => boolean;
/**
* 判断是否没有从源宫位飞化到目标宫位,四化可传入一个数组或者一个字符串,传入四化全部没有飞化到目标宫位才返回true
*
* @version v2.1.0
*
* @param to 目标宫位
* @param withMutagens 四化(禄、权、科、忌)
* @returns {boolean}
*/
notFlyTo: (to: number | PalaceName, withMutagens: Mutagen | Mutagen[]) => boolean;
/**
* 判断宫位是否有自化,传入四化数组时需要全部满足才返回true
*
* @version v2.1.0
*
* @param withMutagens 四化(禄、权、科、忌)
* @returns {boolean}
*/
selfMutaged: (withMutagens: Mutagen | Mutagen[]) => boolean;
/**
* 判断宫位是否有自化,若不传入参数则会判断所有四化,满足一颗即返回true
*
* @version v2.1.0
*
* @param withMutagens 四化(禄、权、科、忌)
* @returns {boolean}
*/
selfMutagedOneOf: (withMutagens?: Mutagen[]) => boolean;
/**
* 判断宫位是否有自化,如果传入参数,则只判断传入的四化是否有自化,否则将会判断所有四化
*
* @version v2.1.0
*
* @param withMutagens 【可选】四化(禄、权、科、忌)
* @returns {boolean}
*/
notSelfMutaged: (withMutagens?: Mutagen | Mutagen[]) => boolean;
/**
* 获取当前宫位产生四化的4个宫位数组,下标分别对【禄,权,科,忌】
*
* @version v2.1.0
*
* @returns {(IFunctionalPalace | undefined)[]}
*/
mutagedPlaces: () => (IFunctionalPalace | undefined)[];
}

@@ -75,3 +159,4 @@ /**

export default class FunctionalPalace implements IFunctionalPalace {
name: import("../i18n").PalaceName;
private _astrolabe?;
name: PalaceName;
isBodyPalace: boolean;

@@ -97,2 +182,11 @@ isOriginalPalace: boolean;

isEmpty: (excludeStars?: StarName[]) => boolean;
setAstrolabe: (astro: IFunctionalAstrolabe) => IFunctionalAstrolabe;
astrolabe: () => IFunctionalAstrolabe | undefined;
fliesTo: (to: number | PalaceName, withMutagens: Mutagen | Mutagen[]) => boolean;
fliesOneOfTo: (to: number | PalaceName, withMutagens: Mutagen[]) => boolean;
notFlyTo: (to: number | PalaceName, withMutagens: Mutagen | Mutagen[]) => boolean;
selfMutaged: (withMutagens: Mutagen | Mutagen[]) => boolean;
selfMutagedOneOf: (withMutagens?: Mutagen[]) => boolean;
notSelfMutaged: (withMutagens?: Mutagen | Mutagen[]) => boolean;
mutagedPlaces: () => (IFunctionalPalace | undefined)[];
}

@@ -27,2 +27,81 @@ "use strict";

};
this.setAstrolabe = function (astro) { return (_this._astrolabe = astro); };
this.astrolabe = function () { return _this._astrolabe; };
this.fliesTo = function (to, withMutagens) {
var _a;
var toPalace = (_a = _this.astrolabe()) === null || _a === void 0 ? void 0 : _a.palace(to);
if (!toPalace) {
return false;
}
var heavenlyStem = _this.heavenlyStem;
var stars = (0, analyzer_1.mutagensToStars)(heavenlyStem, withMutagens);
if (!stars || !stars.length) {
return false;
}
return toPalace.has(stars);
};
this.fliesOneOfTo = function (to, withMutagens) {
var _a;
var toPalace = (_a = _this.astrolabe()) === null || _a === void 0 ? void 0 : _a.palace(to);
if (!toPalace) {
return false;
}
var heavenlyStem = _this.heavenlyStem;
var stars = (0, analyzer_1.mutagensToStars)(heavenlyStem, withMutagens);
if (!stars || !stars.length) {
return true;
}
return toPalace.hasOneOf(stars);
};
this.notFlyTo = function (to, withMutagens) {
var _a;
var toPalace = (_a = _this.astrolabe()) === null || _a === void 0 ? void 0 : _a.palace(to);
if (!toPalace) {
return false;
}
var heavenlyStem = _this.heavenlyStem;
var stars = (0, analyzer_1.mutagensToStars)(heavenlyStem, withMutagens);
if (!stars || !stars.length) {
return true;
}
return toPalace.notHave(stars);
};
this.selfMutaged = function (withMutagens) {
var heavenlyStem = _this.heavenlyStem;
var stars = (0, analyzer_1.mutagensToStars)(heavenlyStem, withMutagens);
return _this.has(stars);
};
this.selfMutagedOneOf = function (withMutagens) {
var muts = [];
if (!withMutagens || !withMutagens.length) {
muts = ['禄', '权', '科', '忌'];
}
else {
muts = withMutagens;
}
var heavenlyStem = _this.heavenlyStem;
var stars = (0, analyzer_1.mutagensToStars)(heavenlyStem, muts);
return _this.hasOneOf(stars);
};
this.notSelfMutaged = function (withMutagens) {
var muts = [];
if (!withMutagens || !withMutagens.length) {
muts = ['禄', '权', '科', '忌'];
}
else {
muts = withMutagens;
}
var heavenlyStem = _this.heavenlyStem;
var stars = (0, analyzer_1.mutagensToStars)(heavenlyStem, muts);
return _this.notHave(stars);
};
this.mutagedPlaces = function () {
var heavenlyStem = _this.heavenlyStem;
var astrolabe = _this.astrolabe();
if (!astrolabe) {
return [];
}
var stars = (0, analyzer_1.mutagensToStars)(heavenlyStem, ['禄', '权', '科', '忌']);
return stars.map(function (star) { return astrolabe.star(star).palace(); });
};
this.name = data.name;

@@ -29,0 +108,0 @@ this.isBodyPalace = data.isBodyPalace;

{
"name": "iztro",
"version": "2.0.8",
"version": "2.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",

@@ -71,2 +71,4 @@ <div align="center">

- 判斷指定宮位是否是空宮
- 判斷宮位是否產生飛星到目標宮位
- 取得宮位產生的四化宮位

@@ -73,0 +75,0 @@ - 其他

@@ -72,2 +72,4 @@ <div align="center">

- 判断指定宫位是否是空宫
- 判断宫位是否产生飞星到目标宫位
- 获取宫位产生的四化宫位

@@ -74,0 +76,0 @@ - 其他

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