UNPKG

lunar-lite

Version:

精简版的农历和阳历日期转换库。

23 lines (22 loc) 737 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fixIndex = void 0; /** * 用于处理索引,将索引锁定在 0~max 范围内 * * @param index 当前索引 * @param max 最大循环数,默认为12【因为12用得最多,宫位数量以及十二地支数量都为12,所以将12作为默认值】 * @returns {number} 处理后的索引 */ var fixIndex = function (index, max) { if (max === void 0) { max = 12; } if (index < 0) { return (0, exports.fixIndex)(index + max, max); } if (index > max - 1) { return (0, exports.fixIndex)(index - max, max); } var res = 1 / index === -Infinity ? 0 : index; return res; }; exports.fixIndex = fixIndex;