liuyao 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/index.d.ts +302 -0
- package/dist/index.mjs +1731 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 kasukabe tsumugi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# liuyao
|
|
2
|
+
|
|
3
|
+
Metadata and utility classes for Chinese Liu Yao divination. This package provides typed models for yao lines and hexagrams, along with traditional metadata derived from sources such as Zeng Shan Bu Yi.
|
|
4
|
+
|
|
5
|
+
For more packages, see [my homepage](https://baendlorel.github.io/?repoType=npm).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Create a yao from its yang-count representation.
|
|
10
|
+
- Build a hexagram from six yao lines or from a known hexagram name.
|
|
11
|
+
- Inspect hexagram metadata such as its name, palace, phase, and setup information.
|
|
12
|
+
- Derive the changed hexagram for dynamic lines.
|
|
13
|
+
- Access six-god ordering data for different heavenly stems.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add liuyao
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { Hexagram, Yao, SixGodList } from 'liuyao';
|
|
25
|
+
|
|
26
|
+
const hexagram = Hexagram.fromYaos([
|
|
27
|
+
new Yao(3),
|
|
28
|
+
new Yao(1),
|
|
29
|
+
new Yao(2),
|
|
30
|
+
new Yao(2),
|
|
31
|
+
new Yao(1),
|
|
32
|
+
new Yao(0),
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
if (!hexagram) {
|
|
36
|
+
throw new Error('Invalid hexagram');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(hexagram.info.id);
|
|
40
|
+
console.log(hexagram.toDescriptionEn());
|
|
41
|
+
console.log(hexagram.toChanged()?.info.id);
|
|
42
|
+
console.log(SixGodList[0]);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Core Concepts
|
|
46
|
+
|
|
47
|
+
### Yao
|
|
48
|
+
|
|
49
|
+
A yao is one line in a hexagram. The constructor accepts a yang count from `0` to `3`:
|
|
50
|
+
|
|
51
|
+
- `0`: old yin, dynamic
|
|
52
|
+
- `1`: young yang, static
|
|
53
|
+
- `2`: young yin, static
|
|
54
|
+
- `3`: old yang, dynamic
|
|
55
|
+
|
|
56
|
+
Example:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { Yao } from 'liuyao';
|
|
60
|
+
|
|
61
|
+
const yao = new Yao(3);
|
|
62
|
+
|
|
63
|
+
console.log(yao.name);
|
|
64
|
+
console.log(yao.symbol);
|
|
65
|
+
console.log(yao.isDynamic);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Hexagram
|
|
69
|
+
|
|
70
|
+
A hexagram contains six yao lines ordered from bottom to top.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { Hexagram } from 'liuyao';
|
|
74
|
+
|
|
75
|
+
const qian = Hexagram.fromId('乾为天');
|
|
76
|
+
|
|
77
|
+
if (qian) {
|
|
78
|
+
console.log(qian.info.sign);
|
|
79
|
+
console.log(qian.info.phase);
|
|
80
|
+
console.log(qian.dynamicInner);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Useful instance members:
|
|
85
|
+
|
|
86
|
+
- `info`: metadata for the current hexagram
|
|
87
|
+
- `isDynamic`: whether any line is dynamic
|
|
88
|
+
- `isChanged`: whether the current hexagram is already a changed hexagram
|
|
89
|
+
- `toChanged()`: returns the changed hexagram when dynamic lines exist
|
|
90
|
+
- `toDescription()`: Chinese description
|
|
91
|
+
- `toDescriptionEn()`: English description
|
|
92
|
+
|
|
93
|
+
Useful factory methods:
|
|
94
|
+
|
|
95
|
+
- `Hexagram.fromYaos(yaos)`
|
|
96
|
+
- `Hexagram.fromYangCounts(counts)`
|
|
97
|
+
- `Hexagram.fromId(id)`
|
|
98
|
+
- `Hexagram.fromPalace(palace)`
|
|
99
|
+
|
|
100
|
+
## Exported API
|
|
101
|
+
|
|
102
|
+
The package currently exports:
|
|
103
|
+
|
|
104
|
+
- `Hexagram`
|
|
105
|
+
- `Yao`
|
|
106
|
+
- `YaoIndex`
|
|
107
|
+
- `SixGodList`
|
|
108
|
+
- type `SixGod`
|
|
109
|
+
- type `SetupGramInfo`
|
|
110
|
+
|
|
111
|
+
## Notes
|
|
112
|
+
|
|
113
|
+
- Traditional names and metadata values are kept in Chinese.
|
|
114
|
+
- The package focuses on data modeling and lookup. It does not implement a full divination workflow by itself.
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kins and their corresponding earthly branches in the Liu Yao divination system, along with the type of relation (世 or 应).
|
|
3
|
+
* This information is crucial for interpreting the hexagrams and their changing lines in the context of a divination reading.
|
|
4
|
+
*/
|
|
5
|
+
interface SetupGramInfo {
|
|
6
|
+
/**
|
|
7
|
+
* There are 5 kins in total.
|
|
8
|
+
*
|
|
9
|
+
* - 兄弟 (Brothers): Representing peers, friends, or competitors.
|
|
10
|
+
* - 妻财 (Wife/Wealth): Representing spouse, wealth, or resources.
|
|
11
|
+
* - 子孙 (Children/Descendants): Representing offspring, students, or followers.
|
|
12
|
+
* - 官鬼 (Officials/Ghosts): Representing authority figures, adversaries, or hidden factors.
|
|
13
|
+
* - 父母 (Parents): Representing parents, mentors, or foundational influences.
|
|
14
|
+
*
|
|
15
|
+
* Each kin is associated with one of the twelve earthly branches (地支), which adds another layer of meaning to the hexagram lines.
|
|
16
|
+
*/
|
|
17
|
+
kin: '兄弟丑土' | '兄弟亥水' | '兄弟午火' | '兄弟卯木' | '兄弟子水' | '兄弟寅木' | '兄弟巳火' | '兄弟戌土' | '兄弟未土' | '兄弟申金' | '兄弟辰土' | '兄弟酉金' | '妻财丑土' | '妻财亥水' | '妻财午火' | '妻财卯木' | '妻财子水' | '妻财寅木' | '妻财巳火' | '妻财戌土' | '妻财未土' | '妻财申金' | '妻财辰土' | '妻财酉金' | '子孙丑土' | '子孙亥水' | '子孙午火' | '子孙卯木' | '子孙子水' | '子孙寅木' | '子孙巳火' | '子孙戌土' | '子孙未土' | '子孙申金' | '子孙辰土' | '子孙酉金' | '官鬼丑土' | '官鬼亥水' | '官鬼午火' | '官鬼卯木' | '官鬼子水' | '官鬼寅木' | '官鬼巳火' | '官鬼戌土' | '官鬼未土' | '官鬼申金' | '官鬼辰土' | '官鬼酉金' | '父母丑土' | '父母亥水' | '父母午火' | '父母卯木' | '父母子水' | '父母寅木' | '父母巳火' | '父母戌土' | '父母未土' | '父母申金' | '父母辰土' | '父母酉金';
|
|
18
|
+
/**
|
|
19
|
+
* Host(世)is the augur and Guest(应) is the person or things which to ask about.
|
|
20
|
+
*
|
|
21
|
+
* Indexes of Host and Guest satisfies this formula:
|
|
22
|
+
* ```js
|
|
23
|
+
* index_guest = (index_host + 3) % 6
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
hostGuest?: '世' | '应';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface PalaceIndexName {
|
|
30
|
+
name: string;
|
|
31
|
+
nameEn: string;
|
|
32
|
+
}
|
|
33
|
+
declare const PalaceIndexList: PalaceIndexName[];
|
|
34
|
+
interface HexagramInfo {
|
|
35
|
+
/**
|
|
36
|
+
* Binary representation of the hexagram, where 0 represents a yin line and 1 represents a yang line. The lines are ordered from the bottom (first line) to the top (sixth line).
|
|
37
|
+
*/
|
|
38
|
+
binary: `${0 | 1}${0 | 1}${0 | 1}${0 | 1}${0 | 1}${0 | 1}`;
|
|
39
|
+
/**
|
|
40
|
+
* Binary to YangCounts.
|
|
41
|
+
* e.g. `'000000'` 坤为地 -> `[2, 2, 2, 2, 2, 2]`, 2 means Shao Yin.
|
|
42
|
+
*/
|
|
43
|
+
yangCounts: number[];
|
|
44
|
+
/**
|
|
45
|
+
* Name of the hexagram, which includes the names of the upper and lower trigrams.
|
|
46
|
+
*
|
|
47
|
+
* For example, "坤为地", "地雷复", "地水师", etc.
|
|
48
|
+
*/
|
|
49
|
+
id: string;
|
|
50
|
+
/**
|
|
51
|
+
* 64 hexagrams correspond to Unicode characters.
|
|
52
|
+
* For example, "䷁" (U+4DC1) represents the hexagram "坤为地".
|
|
53
|
+
*/
|
|
54
|
+
sign: string;
|
|
55
|
+
/**
|
|
56
|
+
* Five Phases (五行) associated with the hexagram, which can be one of "金" (Metal), "木" (Wood), "水" (Water), "火" (Fire), or "土" (Earth).
|
|
57
|
+
* It indicates the development and state of things.
|
|
58
|
+
*/
|
|
59
|
+
phase: '金' | '木' | '水' | '火' | '土';
|
|
60
|
+
/**
|
|
61
|
+
* Eight Palaces (八宫) to which the hexagram belongs.
|
|
62
|
+
* 'Palace' is not a physical palace, but rather a category or family of hexagrams.
|
|
63
|
+
*/
|
|
64
|
+
palace: '乾' | '兑' | '离' | '震' | '巽' | '坎' | '艮' | '坤';
|
|
65
|
+
/**
|
|
66
|
+
* Index of the hexagram within its palace, ranging from 0 to 7. This index helps to identify the specific hexagram within the context of its palace.
|
|
67
|
+
*
|
|
68
|
+
* - 本宫卦 Original Palace
|
|
69
|
+
* - 一世卦 First Generation, 1st yao is changed
|
|
70
|
+
* - 二世卦 Second Generation, 1st and 2nd yao is changed
|
|
71
|
+
* - 三世卦 Third Generation, 1st, 2nd and 3rd yao is changed
|
|
72
|
+
* - 四世卦 Fourth Generation, 1st, 2nd, 3rd and 4th yao is changed
|
|
73
|
+
* - 五世卦 Fifth Generation, 1st, 2nd, 3rd, 4th and 5th yao is changed
|
|
74
|
+
* - 游魂卦 Wandering Soul, restores 4th yao of Fifth Generation
|
|
75
|
+
* - 归魂卦 Returning Soul, restores lower 3 yaos of Fifth Generation
|
|
76
|
+
*/
|
|
77
|
+
palaceIndex: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
78
|
+
/**
|
|
79
|
+
* Setup information of the hexagram. Includes Host-Guest(世应) and Six Kins (六亲) for each of the six lines. This information is crucial for interpreting the hexagrams and their changing lines in the context of a divination reading.
|
|
80
|
+
*
|
|
81
|
+
* Host(世)is the augur and Guest(应) is the person or things which to ask about.
|
|
82
|
+
*/
|
|
83
|
+
setupInfo: [SetupGramInfo, SetupGramInfo, SetupGramInfo, SetupGramInfo, SetupGramInfo, SetupGramInfo];
|
|
84
|
+
}
|
|
85
|
+
declare const HexagramList: readonly HexagramInfo[];
|
|
86
|
+
interface TrigramInfo {
|
|
87
|
+
/**
|
|
88
|
+
* Presents the trigram as a 3-digit binary string. 1 represents a Yang line and 0 represents a Yin line.
|
|
89
|
+
*
|
|
90
|
+
* For example, "111" for 乾, "100" for 震, etc.
|
|
91
|
+
*/
|
|
92
|
+
binary: `${0 | 1}${0 | 1}${0 | 1}`;
|
|
93
|
+
/**
|
|
94
|
+
* How many Yang Yaos are in the trigram, such as 0 for 坤, 1 for 震, 2 for 兑, etc.
|
|
95
|
+
*/
|
|
96
|
+
yangCount: 0 | 1 | 2 | 3;
|
|
97
|
+
/**
|
|
98
|
+
* Name of the trigram in Chinese, such as "乾", "坤", "震", etc.
|
|
99
|
+
*/
|
|
100
|
+
id: string;
|
|
101
|
+
/**
|
|
102
|
+
* Name of the trigram in English, such as "Qian", "Kun", "Zhen", etc.
|
|
103
|
+
*/
|
|
104
|
+
nameEn: string;
|
|
105
|
+
/**
|
|
106
|
+
* What the trigram represents in Chinese, such as "天", "地", "水", etc.
|
|
107
|
+
*/
|
|
108
|
+
represents: string;
|
|
109
|
+
/**
|
|
110
|
+
* What the trigram represents in English, such as "heaven", "earth", "water", etc.
|
|
111
|
+
*/
|
|
112
|
+
representsEn: string;
|
|
113
|
+
/**
|
|
114
|
+
* Unicode character representing the trigram, such as "☰" for 乾, "☷" for 坤, etc.
|
|
115
|
+
*/
|
|
116
|
+
sign: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* List of all trigrams in the I Ching, with their binary representation, number of yang lines, name, what they represent, and their corresponding sign.
|
|
120
|
+
*/
|
|
121
|
+
declare const TrigramList: readonly TrigramInfo[];
|
|
122
|
+
|
|
123
|
+
type SixGod = '玄武' | '白虎' | '螣蛇' | '勾陈' | '朱雀' | '青龙';
|
|
124
|
+
interface SixGodInfo {
|
|
125
|
+
/**
|
|
126
|
+
* The Heavenly Stem associated with the Six Gods in this order.
|
|
127
|
+
* They are '甲乙丙丁戊己庚辛壬癸' in sequence.
|
|
128
|
+
* Different Heavenly Stems correspond to different orders of Six Gods.
|
|
129
|
+
*/
|
|
130
|
+
heavenlyStem: string;
|
|
131
|
+
/**
|
|
132
|
+
* Six Gods contains '青龙', '朱雀', '勾陈', '螣蛇', '白虎', '玄武'.
|
|
133
|
+
* Different Heavenly Stems correspond to different orders of Six Gods.
|
|
134
|
+
*
|
|
135
|
+
* Six Gods are all auspicious symbols and protectors.
|
|
136
|
+
* - 青龙: Azure Loong, the God in the East worshipped by the Taoists.
|
|
137
|
+
* - 朱雀: Vermilion Bird, its body is covered with eternal fire.
|
|
138
|
+
* - 白虎: White Tiger, as white as snow. If the emperor is not cruel and tyrannical, the White Tiger will appear.
|
|
139
|
+
* - 玄武:Black Tortoise, a spiritual creature formed by the combination of a tortoise and a snake.
|
|
140
|
+
* - 螣蛇: Flying Serpent, a limbless divine serpent that can summon clouds and mist and roam within them.
|
|
141
|
+
* - 勾陈: Gouchen, Also considered as 麒麟 Kylin. It has a body like a musk deer, a tail like that of a dragon, dragon scales, and a single horn.
|
|
142
|
+
*/
|
|
143
|
+
gods: SixGod[];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @see 《增删卜易·六神章》
|
|
147
|
+
*/
|
|
148
|
+
declare const SixGodList: readonly SixGodInfo[];
|
|
149
|
+
|
|
150
|
+
declare class Yao {
|
|
151
|
+
static getName(yangCount: number): "老阴" | "少阳" | "少阴" | "老阳";
|
|
152
|
+
/**
|
|
153
|
+
* Support creating a Yao from various types of input:
|
|
154
|
+
* - A symbol representing the Yao (e.g. '交', '单', '拆', '重')
|
|
155
|
+
* - A name representing the Yao (e.g. '老阴', '少阳', '少阴', '老阳')
|
|
156
|
+
* - A digit representing the count of yang (e.g. '0', '1', '2', '3')
|
|
157
|
+
* - Symbols in ancient books representing a Yao ()
|
|
158
|
+
* - A field of a TrigramInfo object (e.g. id, binary, nameEn, represents, representsEn, sign)
|
|
159
|
+
* If the input matches any of these, a corresponding Yao will be created.
|
|
160
|
+
* Otherwise, null will be returned.
|
|
161
|
+
*/
|
|
162
|
+
/**
|
|
163
|
+
* Creating a Yao from symbol.
|
|
164
|
+
* @param symbol e.g. '×' for 0, '’' for 1, '”' for 2, '○' for 3.
|
|
165
|
+
*/
|
|
166
|
+
static fromSymbol(symbol: string): Yao | null;
|
|
167
|
+
/**
|
|
168
|
+
* Creating a Yao from symbolName.
|
|
169
|
+
* @param symbolName e.g. '交' for 0, '单' for 1, '拆' for 2, '重' for 3.
|
|
170
|
+
*/
|
|
171
|
+
static fromSymbolName(symbolName: string): Yao | null;
|
|
172
|
+
/**
|
|
173
|
+
* Creating a Yao from name.
|
|
174
|
+
* @param name e.g. '老阴', '少阳', '少阴', '老阳'.
|
|
175
|
+
*/
|
|
176
|
+
static fromName(name: string): Yao | null;
|
|
177
|
+
/**
|
|
178
|
+
* Create a Yao from a digit string representing the count of yang.
|
|
179
|
+
*/
|
|
180
|
+
static fromDigitString(digit: string): Yao | null;
|
|
181
|
+
/**
|
|
182
|
+
* Create a Yao from any Trigram field value.
|
|
183
|
+
* @param value `{id: '坤', binary: '000', yangCount: 0}`, so `'坤'`, `'000'` and `0` can all be used.
|
|
184
|
+
*/
|
|
185
|
+
static fromTrigramField(value: string | number): Yao | null;
|
|
186
|
+
private _yangCount;
|
|
187
|
+
/**
|
|
188
|
+
* How many faces of character of 3 coins in this Yao.
|
|
189
|
+
* It can only be 0, 1, 2 or 3, which corresponds to 老阴、少阳、少阴、老阳 respectively.
|
|
190
|
+
* - 0: 老阴 (all three coins are Yin)
|
|
191
|
+
* - 1: 少阳 (one coin is Yang, two coins are Yin)
|
|
192
|
+
* - 2: 少阴 (two coins are Yang, one coin is Yin)
|
|
193
|
+
* - 3: 老阳 (all three coins are Yang)
|
|
194
|
+
*/
|
|
195
|
+
get yangCount(): 0 | 1 | 2 | 3;
|
|
196
|
+
/**
|
|
197
|
+
* Two Polars.
|
|
198
|
+
* - 0 represents Yin 阴
|
|
199
|
+
* - 1 represents Yang 阳
|
|
200
|
+
*/
|
|
201
|
+
get polar(): 0 | 1;
|
|
202
|
+
/**
|
|
203
|
+
* If this Yao is dynamic, which means it can change to another Yao. In LiuYao, only 老阴 and 老阳 are dynamic.
|
|
204
|
+
* - 老阴 (0) can change to 少阳 (1)
|
|
205
|
+
* - 老阳 (3) can change to 少阴 (2)
|
|
206
|
+
* - 少阳 (1) and 少阴 (2) cannot change, so they are static.
|
|
207
|
+
*/
|
|
208
|
+
get isDynamic(): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Whether this Yao has already changed to another Yao. Once a Yao is changed, it cannot change again.
|
|
211
|
+
*/
|
|
212
|
+
readonly isChanged: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* @returns The symbol representing this Yao, which is one of '×', '’', '”', '○'.
|
|
215
|
+
*/
|
|
216
|
+
get symbol(): string;
|
|
217
|
+
get symbolName(): string;
|
|
218
|
+
get name(): "老阴" | "少阳" | "少阴" | "老阳";
|
|
219
|
+
constructor(yangCount: number, isChanged?: boolean);
|
|
220
|
+
/**
|
|
221
|
+
* Change `this.yangCount`
|
|
222
|
+
*/
|
|
223
|
+
set(yangCount: number): void;
|
|
224
|
+
clone(): Yao;
|
|
225
|
+
toChanged(): Yao;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
type LiuYao = [Yao, Yao, Yao, Yao, Yao, Yao];
|
|
229
|
+
declare const YaoIndex: readonly ["初爻", "二爻", "三爻", "四爻", "五爻", "上爻"];
|
|
230
|
+
/**
|
|
231
|
+
* Hexagram class represents a hexagram, which consists of 6 Yao.
|
|
232
|
+
* - Each Yao can be either yin or yang, and can be changing or not.
|
|
233
|
+
* - The hexagram can be constructed from an array of Yao or an array of counts of yang.
|
|
234
|
+
* - Creates “乾为天” by default.
|
|
235
|
+
*/
|
|
236
|
+
declare class Hexagram {
|
|
237
|
+
/**
|
|
238
|
+
* Use tokens like `'012132'` to create a Hexagram, where each digit represents the count of Yang in the corresponding Yao (0 for 老阴, 1 for 少阳, 2 for 少阴, 3 for 老阳). The first digit represents the first Yao (初爻) and the last digit represents the sixth Yao (上爻).
|
|
239
|
+
*/
|
|
240
|
+
static fromBinary(quaternary: string): Hexagram | null;
|
|
241
|
+
/**
|
|
242
|
+
* Use tokens like `'单单拆拆重重'` to create a Hexagram.
|
|
243
|
+
*
|
|
244
|
+
* Since 交 is 0, 单 is 1, 拆 is 2, and 重 is 3, the above token is equivalent to '112233'.
|
|
245
|
+
* Which returns '风泽中孚' with its 5th and 6th Yao being dynamic.
|
|
246
|
+
*/
|
|
247
|
+
static fromSymbolName(symbolNames: string): Hexagram | null;
|
|
248
|
+
/**
|
|
249
|
+
* Try to create a Hexagram from an array of counts of Yang. If the input is invalid, null will be returned.
|
|
250
|
+
*/
|
|
251
|
+
static fromYangCounts(counts: number[]): Hexagram | null;
|
|
252
|
+
static fromId(id: string): Hexagram | null;
|
|
253
|
+
/**
|
|
254
|
+
* Find Original Palace Hexagram by the palace name, which is the last character of the hexagram id. For example, '天' for '乾为天', '地' for '坤为地', etc.
|
|
255
|
+
*/
|
|
256
|
+
static fromPalace(palace: string): Hexagram | null;
|
|
257
|
+
/**
|
|
258
|
+
* 6 Yao positions, indexed from bottom to top.
|
|
259
|
+
* Index from 0 to 5, where 0 is the first Yao (初爻) and 5 is the sixth Yao (上爻).
|
|
260
|
+
*/
|
|
261
|
+
readonly yaos: LiuYao;
|
|
262
|
+
/**
|
|
263
|
+
* HexagramInfo of this hexagram, which can be used to get more information about this hexagram, such as its name, sign, phase, palace, etc.
|
|
264
|
+
*/
|
|
265
|
+
get info(): HexagramInfo;
|
|
266
|
+
/**
|
|
267
|
+
* Whether the 6 Yaos of this hexagram contain any dynamic Yao.
|
|
268
|
+
*/
|
|
269
|
+
get isDynamic(): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Whether this hexagram has already changed to another hexagram. Once a hexagram is changed, it cannot change again.
|
|
272
|
+
*/
|
|
273
|
+
get isChanged(): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Outer trigram of this hexagram, which consists of the last three yao (四爻、五爻、上爻).
|
|
276
|
+
* @returns A trigram if the outer trigram is dynamic.
|
|
277
|
+
*/
|
|
278
|
+
get dynamicOuter(): boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Inner trigram of this hexagram, which consists of the first three yao (初爻、二爻、三爻).
|
|
281
|
+
* @returns A trigram if the inner trigram is dynamic.
|
|
282
|
+
*/
|
|
283
|
+
get dynamicInner(): boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Create a Hexagram from an array of Yao with length 6.
|
|
286
|
+
*/
|
|
287
|
+
constructor(yaos: Yao[]);
|
|
288
|
+
setYao(index: number, yangCount: number): void;
|
|
289
|
+
toChanged(): Hexagram | null;
|
|
290
|
+
/**
|
|
291
|
+
* Describe this hexagram in a human-readable way, including the original hexagram, the changed hexagram (if any), and the dynamic yao (if any).
|
|
292
|
+
* - e.g.:“本卦乾为天,变卦坤为地,动爻:初爻、三爻”
|
|
293
|
+
*/
|
|
294
|
+
toDescription(): string;
|
|
295
|
+
toDescriptionEn(): string;
|
|
296
|
+
clone(): Hexagram;
|
|
297
|
+
toString(): string;
|
|
298
|
+
[Symbol.toPrimitive](hint: string): string;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export { Hexagram, HexagramList, PalaceIndexList, SixGodList, TrigramList, Yao, YaoIndex };
|
|
302
|
+
export type { HexagramInfo, SetupGramInfo, SixGod, SixGodInfo, TrigramInfo };
|