fortel-codex.js
This node.js module is a library for some basic codex of Chinese Astrology. It included "陰陽", "五行", "天干", "地支", "生肖".
Project page
Wiki pages for Chinese Astrology:
Install
$ npm install --save fortel-codex
Samples
MoonSun(陰陽)
const fortelCodex = ;const MoonSun = fortelCodexMoonSun; var moon = MoonSun;moon = MoonSunMoon; //or equivalentlyconsole; var sun = MoonSun;sun = MoonSunSun; //or equivalentlyconsole;
Console output
陰: MoonSun { index: 0, displayName: '陰' }
陽: MoonSun { index: 1, displayName: '陽' }
Element(五行)
基本五行
const Element = fortelCodexElement; /* 基本五行 Object */var gold = ElementGold;gold = Element; //or equivalentlyconsole; var wood = ElementWood;wood = Element; //or equivalentlyconsole; var earth = ElementEarth;earth = Element; //or equivalentlyconsole; var water = ElementWater;water = Element; //or equivalentlyconsole; var fire = ElementFire;fire = Element; //or equivalentlyconsole;
Console output
金: Element { index: 0, displayName: '金' }
木: Element { index: 1, displayName: '木' }
土: Element { index: 2, displayName: '土' }
水: Element { index: 3, displayName: '水' }
火: Element { index: 4, displayName: '火' }
五行關係
console;console;console;console;console;console; console; console;console;console;console;console;
Console output
五行生剋關係1:
金同金
金剋木
金被生土
金生水
金被剋火
五行生剋關係2:
金生水
金被土所生
金剋木
金被火所剋
Stem(天干)
Array of Stem object(天干)
const fortelCodex = ;const Stem = fortelCodexStem; /* 基本天干 Object */var items = Stemitems; //Array of "天干"var output = "";forlet item of items output += itemdisplayName;console;
Console output
甲乙丙丁戊己庚辛壬癸
Get by index
const util = ;const fortelCodex = ;const Stem = fortelCodexStem; /* Get 天干 by index */console;console;console;
Console output
0: Stem {
index: 0,
displayName: '甲',
moonSun: MoonSun { index: 1, displayName: '陽' },
element: Element { index: 1, displayName: '木' } }
1: Stem {
index: 1,
displayName: '乙',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 1, displayName: '木' } }
Get by name
const util = ;const fortelCodex = ;const Stem = fortelCodexStem; /* Get 天干 by display name */console;console;console;
Console output
0: Stem {
index: 0,
displayName: '甲',
moonSun: MoonSun { index: 1, displayName: '陽' },
element: Element { index: 1, displayName: '木' } }
1: Stem {
index: 1,
displayName: '乙',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 1, displayName: '木' } }
天干合化
/* 天干合化 */console; //甲己合化土console; //乙庚合化金console; //丙辛合化水console; //丁壬合化木console; //戊癸合化火
Console output
甲己合化土
乙庚合化金
丙辛合化水
丁壬合化木
戊癸合化火
天干相剋
/* 天干相剋 */console;console;
Console output
甲剋戊
戊被甲所剋
Branch(地支)
Array of Branch object(地支)
const fortelCodex = ;const Branch = fortelCodexBranch; /* 基本地支 Object */var items = Branchitems; //Array of "地支"var output = "";forlet item of items output += itemdisplayName;console;
Console output
子丑寅卯辰巳午未申酉戌亥
Get by index
/* Get 地支 by index */console;console;console;
Console output
0: Branch {
index: 0,
displayName: '子',
moonSun: MoonSun { index: 1, displayName: '陽' },
element: Element { index: 3, displayName: '水' },
baseStem:
Stem {
index: 9,
displayName: '癸',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 3, displayName: '水' } },
collectStem: null,
remainStem: null }
1: Branch {
index: 1,
displayName: '丑',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 2, displayName: '土' },
baseStem:
Stem {
index: 5,
displayName: '己',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 2, displayName: '土' } },
collectStem:
Stem {
index: 7,
displayName: '辛',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 0, displayName: '金' } },
remainStem:
Stem {
index: 9,
displayName: '癸',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 3, displayName: '水' } } }
......
Get by name
const util = ;const fortelCodex = ;const Stem = fortelCodexStem; /* Get 地支 by display name */console;console;console;
Console output
0: Branch {
index: 0,
displayName: '子',
moonSun: MoonSun { index: 1, displayName: '陽' },
element: Element { index: 3, displayName: '水' },
baseStem:
Stem {
index: 9,
displayName: '癸',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 3, displayName: '水' } },
collectStem: null,
remainStem: null }
1: Branch {
index: 1,
displayName: '丑',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 2, displayName: '土' },
baseStem:
Stem {
index: 5,
displayName: '己',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 2, displayName: '土' } },
collectStem:
Stem {
index: 7,
displayName: '辛',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 0, displayName: '金' } },
remainStem:
Stem {
index: 9,
displayName: '癸',
moonSun: MoonSun { index: 0, displayName: '陰' },
element: Element { index: 3, displayName: '水' } } }
......
地支六合局
/* Get 地支六合局 */let combinations = Branch;console; console;
Console output
子丑合化土
寅亥合化木
地支三合局
/* Get 地支三合局 */let combinations = Branch;console; console;
Console output
申子辰三合水局
寅戌合火局
地支相沖
/* Get 地支相沖 */console;console;
Console output
true
false
地支相刑
/* Get 地支相刑 */let combinations = Branch;console; combinations = Branch;console;
Console output
無恩之刑
自刑
地支相害
/* Get 地支相害 *//* Get 地支相刑 */console;console;
Console output
true
false
BranchHour(時辰)
Array of BranchHour object(時辰)
const fortelCodex = ;const BranchHour = fortelCodexBranchHour; var items = BranchHouritems; //Array of "時辰"console;
Console output
早子, 丑, 寅, 卯, 辰, 巳, 午, 未, 申, 酉, 戌, 亥, 晚子
Zodiac(生肖)
Array of Zodiac object(生肖)
const fortelCodex = ;const Zodiac = fortelCodexZodiac; var items = Zodiacitems; //Array of "生肖"console;
Console output
鼠, 牛, 虎, 兔, 龍, 蛇, 馬, 羊, 猴, 雞, 狗, 豬
API
(Will update later)
Author Contact
- Eric Yu: airic.yu@gmail.com