wadjet
Version:
The your birth date is based on statistical psychology and will expose your personality. This package as a mocule does its calculations.
33 lines (27 loc) • 1.34 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
require('../type');
/** Max value. */
var MAX = Number.MAX_VALUE;
/**
* Correspondence table of life-base factor corresponding to the month and
* day coefficient threshold.
* @type {Wadjet.LifeBaseCoef[][]}
*/
var table = [[{ t: 9, v: 10 }, { t: 13, v: 8 }, { t: MAX, v: 6 }], [{ t: 3, v: 6 }, { t: 5, v: 5 }, { t: 14, v: 3 }, { t: MAX, v: 1 }], [{ t: 10, v: 1 }, { t: MAX, v: 2 }], [{ t: 9, v: 2 }, { t: 13, v: 10 }, { t: MAX, v: 5 }], [{ t: 5, v: 5 }, { t: 14, v: 7 }, { t: MAX, v: 3 }], [{ t: 10, v: 3 }, { t: MAX, v: 4 }], [{ t: 9, v: 4 }, { t: 13, v: 2 }, { t: MAX, v: 6 }], [{ t: 3, v: 6 }, { t: 5, v: 5 }, { t: 14, v: 9 }, { t: MAX, v: 7 }], [{ t: 10, v: 7 }, { t: MAX, v: 8 }], [{ t: 9, v: 8 }, { t: 13, v: 4 }, { t: MAX, v: 5 }], [{ t: 5, v: 5 }, { t: 14, v: 1 }, { t: MAX, v: 9 }], [{ t: 10, v: 9 }, { t: MAX, v: 10 }]];
/**
* Get life-base factor from month, day and coefficient.
* @param {number} month Month. (1-12)
* @param {number} dcoef Coefficient of day.
* @returns {number} Life-base factor.
*/
var lifeBaseCoef = function lifeBaseCoef(month, dcoef) {
return function (r, d) {
return !r ? Number.NaN : r.find(function (v) {
return d < v.t;
}).v;
}(table[month - 1], dcoef);
};
exports.default = lifeBaseCoef;