iching-shifa 1.0.1 → 1.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/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +35 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -208,6 +208,51 @@ function getMovingYaoPositions(yaoString) {
|
|
|
208
208
|
}
|
|
209
209
|
return positions;
|
|
210
210
|
}
|
|
211
|
+
const NUM_TO_TRIGRAM = {
|
|
212
|
+
1: "777",
|
|
213
|
+
2: "778",
|
|
214
|
+
3: "787",
|
|
215
|
+
4: "788",
|
|
216
|
+
5: "877",
|
|
217
|
+
6: "878",
|
|
218
|
+
7: "887",
|
|
219
|
+
8: "888"
|
|
220
|
+
};
|
|
221
|
+
function modWithZero(num, divisor) {
|
|
222
|
+
const remainder = num % divisor;
|
|
223
|
+
return remainder === 0 ? divisor : remainder;
|
|
224
|
+
}
|
|
225
|
+
function buildYaoString(upperNum, lowerNum, dongYao) {
|
|
226
|
+
const yaoArray = (NUM_TO_TRIGRAM[lowerNum] + NUM_TO_TRIGRAM[upperNum]).split("").map((c) => parseInt(c, 10));
|
|
227
|
+
const dongIndex = dongYao - 1;
|
|
228
|
+
if (yaoArray[dongIndex] === 7) {
|
|
229
|
+
yaoArray[dongIndex] = 9;
|
|
230
|
+
} else if (yaoArray[dongIndex] === 8) {
|
|
231
|
+
yaoArray[dongIndex] = 6;
|
|
232
|
+
}
|
|
233
|
+
return yaoArray.join("");
|
|
234
|
+
}
|
|
235
|
+
function threeNumberQiGua(num1, num2, num3) {
|
|
236
|
+
const upperNum = modWithZero(num1, 8);
|
|
237
|
+
const lowerNum = modWithZero(num2, 8);
|
|
238
|
+
const dongYao = modWithZero(num3, 6);
|
|
239
|
+
return buildYaoString(upperNum, lowerNum, dongYao);
|
|
240
|
+
}
|
|
241
|
+
function numberArrayQiGua(numbers, hourZhiIndex) {
|
|
242
|
+
if (numbers.length < 2) {
|
|
243
|
+
throw new Error("数组起卦至少需要2个数字");
|
|
244
|
+
}
|
|
245
|
+
const len = numbers.length;
|
|
246
|
+
const splitIndex = Math.floor(len / 2);
|
|
247
|
+
const firstHalf = numbers.slice(0, splitIndex);
|
|
248
|
+
const secondHalf = numbers.slice(splitIndex);
|
|
249
|
+
const firstSum = firstHalf.reduce((a, b) => a + b, 0);
|
|
250
|
+
const secondSum = secondHalf.reduce((a, b) => a + b, 0);
|
|
251
|
+
const upperNum = modWithZero(firstSum, 8);
|
|
252
|
+
const lowerNum = modWithZero(secondSum, 8);
|
|
253
|
+
const dongYao = modWithZero(upperNum + lowerNum + hourZhiIndex, 6);
|
|
254
|
+
return buildYaoString(upperNum, lowerNum, dongYao);
|
|
255
|
+
}
|
|
211
256
|
const BAGUA_XIANG = {
|
|
212
257
|
"1": "天",
|
|
213
258
|
"2": "澤",
|
|
@@ -5859,9 +5904,11 @@ exports.getWuXingRelation = getWuXingRelation;
|
|
|
5859
5904
|
exports.getZhiGua = getZhiGua;
|
|
5860
5905
|
exports.isMovingYao = isMovingYao;
|
|
5861
5906
|
exports.manualQiGua = manualQiGua;
|
|
5907
|
+
exports.numberArrayQiGua = numberArrayQiGua;
|
|
5862
5908
|
exports.rotateList = rotateList;
|
|
5863
5909
|
exports.rotateListByIndex = rotateListByIndex;
|
|
5864
5910
|
exports.solarToLunar = solarToLunar;
|
|
5911
|
+
exports.threeNumberQiGua = threeNumberQiGua;
|
|
5865
5912
|
exports.timeQiGua = timeQiGua;
|
|
5866
5913
|
exports.wuXingToLiuQin = wuXingToLiuQin;
|
|
5867
5914
|
//# sourceMappingURL=index.cjs.map
|