@hestia-earth/utils
Advanced tools
Comparing version 0.10.20 to 0.10.21
@@ -7,1 +7,2 @@ export declare const secondMs = 1000; | ||
export declare const diffInYears: (date1: Date | string, date2: Date | string) => number; | ||
export declare const daysBefore: (date?: Date, days?: number) => Date; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.diffInYears = exports.diffInDays = exports.dayMs = exports.hourMs = exports.minuteMs = exports.secondMs = void 0; | ||
exports.daysBefore = exports.diffInYears = exports.diffInDays = exports.dayMs = exports.hourMs = exports.minuteMs = exports.secondMs = void 0; | ||
exports.secondMs = 1000; | ||
@@ -17,1 +17,9 @@ exports.minuteMs = 60 * exports.secondMs; | ||
exports.diffInYears = diffInYears; | ||
var daysBefore = function (date, days) { | ||
if (date === void 0) { date = new Date(); } | ||
if (days === void 0) { days = 1; } | ||
var newDate = new Date(date); | ||
newDate.setDate(date.getDate() - days); | ||
return newDate; | ||
}; | ||
exports.daysBefore = daysBefore; |
@@ -8,3 +8,30 @@ export declare const isNumber: (n: string | number) => boolean; | ||
MJ = "MJ", | ||
kWh = "kWh" | ||
kWh = "kWh", | ||
kgCa = "kg Ca", | ||
kgCaCO3 = "kg CaCO3", | ||
kgCaO = "kg CaO", | ||
kgCH4 = "kg CH4", | ||
kgCH4C = "kg CH4-C", | ||
kgCO2 = "kg CO2", | ||
kgCO2C = "kg CO2-C", | ||
kgK = "kg K", | ||
kgK2O = "kg K2O", | ||
kgMgCO3 = "kg MgCO3", | ||
kgN2 = "kg N2", | ||
kgN2N = "kg N2-N", | ||
kgN2O = "kg N2O", | ||
kgN2ON = "kg N2O-N", | ||
kgNH3 = "kg NH3", | ||
kgNH3N = "kg NH3-N", | ||
kgNH4 = "kg NH4", | ||
kgNH4N = "kg NH4-N", | ||
kgNO2 = "kg NO2", | ||
kgNO2N = "kg NO2-N", | ||
kgNO3 = "kg NO3", | ||
kgNO3N = "kg NO3-N", | ||
kgNOx = "kg NOx", | ||
kgNOxN = "kg NOx-N", | ||
kgP = "kg P", | ||
kgP2O5 = "kg P2O5", | ||
kgPO43 = "kg PO43" | ||
} | ||
@@ -15,3 +42,3 @@ export interface IConvertArgs { | ||
export declare const converters: { | ||
[fromUnit in ConvertUnits]: { | ||
[fromUnit in ConvertUnits]?: { | ||
[toUnit in ConvertUnits]?: (value: number, args: IConvertArgs) => number; | ||
@@ -18,0 +45,0 @@ }; |
"use strict"; | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,2 +14,9 @@ exports.convertValue = exports.converters = exports.ConvertUnits = exports.toPrecision = exports.isNumber = void 0; | ||
exports.toPrecision = toPrecision; | ||
var C = 12.012; | ||
var CA = 40.078; | ||
var H = 1.008; | ||
var K = 39.098; | ||
var N = 14.007; | ||
var O = 15.999; | ||
var P = 30.974; | ||
var ConvertUnits; | ||
@@ -22,2 +29,29 @@ (function (ConvertUnits) { | ||
ConvertUnits["kWh"] = "kWh"; | ||
ConvertUnits["kgCa"] = "kg Ca"; | ||
ConvertUnits["kgCaCO3"] = "kg CaCO3"; | ||
ConvertUnits["kgCaO"] = "kg CaO"; | ||
ConvertUnits["kgCH4"] = "kg CH4"; | ||
ConvertUnits["kgCH4C"] = "kg CH4-C"; | ||
ConvertUnits["kgCO2"] = "kg CO2"; | ||
ConvertUnits["kgCO2C"] = "kg CO2-C"; | ||
ConvertUnits["kgK"] = "kg K"; | ||
ConvertUnits["kgK2O"] = "kg K2O"; | ||
ConvertUnits["kgMgCO3"] = "kg MgCO3"; | ||
ConvertUnits["kgN2"] = "kg N2"; | ||
ConvertUnits["kgN2N"] = "kg N2-N"; | ||
ConvertUnits["kgN2O"] = "kg N2O"; | ||
ConvertUnits["kgN2ON"] = "kg N2O-N"; | ||
ConvertUnits["kgNH3"] = "kg NH3"; | ||
ConvertUnits["kgNH3N"] = "kg NH3-N"; | ||
ConvertUnits["kgNH4"] = "kg NH4"; | ||
ConvertUnits["kgNH4N"] = "kg NH4-N"; | ||
ConvertUnits["kgNO2"] = "kg NO2"; | ||
ConvertUnits["kgNO2N"] = "kg NO2-N"; | ||
ConvertUnits["kgNO3"] = "kg NO3"; | ||
ConvertUnits["kgNO3N"] = "kg NO3-N"; | ||
ConvertUnits["kgNOx"] = "kg NOx"; | ||
ConvertUnits["kgNOxN"] = "kg NOx-N"; | ||
ConvertUnits["kgP"] = "kg P"; | ||
ConvertUnits["kgP2O5"] = "kg P2O5"; | ||
ConvertUnits["kgPO43"] = "kg PO43"; | ||
})(ConvertUnits = exports.ConvertUnits || (exports.ConvertUnits = {})); | ||
@@ -43,2 +77,51 @@ exports.converters = (_a = {}, | ||
_f), | ||
_a[ConvertUnits.kgP] = (_g = {}, | ||
_g[ConvertUnits.kgP2O5] = function (value) { return value * (P * 2) / (P * 2 + O * 5); }, | ||
_g[ConvertUnits.kgPO43] = function (value) { return value * P / ((P + O * 4) * 3); }, | ||
_g), | ||
_a[ConvertUnits.kgPO43] = (_h = {}, | ||
_h[ConvertUnits.kgP2O5] = function (value) { return value * ((P + O * 4) * 3) / (P * 2 + O * 5); }, | ||
_h), | ||
_a[ConvertUnits.kgK] = (_j = {}, | ||
_j[ConvertUnits.kgK2O] = function (value) { return value * (K * 2) / (K * 2 + O); }, | ||
_j), | ||
_a[ConvertUnits.kgCa] = (_k = {}, | ||
_k[ConvertUnits.kgCaO] = function (value) { return value * CA / (CA + O); }, | ||
_k), | ||
_a[ConvertUnits.kgCaO] = (_l = {}, | ||
_l[ConvertUnits.kgCaCO3] = function (value) { return value * (CA + O) / (CA + C + O * 3); }, | ||
_l), | ||
_a[ConvertUnits.kgCaCO3] = (_m = {}, | ||
_m[ConvertUnits.kgCO2] = function (value) { return value * 0.12; }, | ||
_m), | ||
_a[ConvertUnits.kgMgCO3] = (_o = {}, | ||
_o[ConvertUnits.kgCO2] = function (value) { return value * 0.13; }, | ||
_o), | ||
_a[ConvertUnits.kgCH4] = (_p = {}, | ||
_p[ConvertUnits.kgCH4C] = function (value) { return value * (C + H * 4) / C; }, | ||
_p), | ||
_a[ConvertUnits.kgCO2] = (_q = {}, | ||
_q[ConvertUnits.kgCO2C] = function (value) { return value * (C + O * 2) / C; }, | ||
_q), | ||
_a[ConvertUnits.kgNOx] = (_r = {}, | ||
_r[ConvertUnits.kgNOxN] = function (value) { return value * (N + O) / N; }, | ||
_r), | ||
_a[ConvertUnits.kgN2] = (_s = {}, | ||
_s[ConvertUnits.kgN2N] = function (value) { return value * 1; }, | ||
_s), | ||
_a[ConvertUnits.kgN2O] = (_t = {}, | ||
_t[ConvertUnits.kgN2ON] = function (value) { return value * (N * 2 + O) / (N * 2); }, | ||
_t), | ||
_a[ConvertUnits.kgNO2] = (_u = {}, | ||
_u[ConvertUnits.kgNO2N] = function (value) { return value * (N + O * 2) / N; }, | ||
_u), | ||
_a[ConvertUnits.kgNO3] = (_v = {}, | ||
_v[ConvertUnits.kgNO3N] = function (value) { return value * (N + O * 3) / N; }, | ||
_v), | ||
_a[ConvertUnits.kgNH3] = (_w = {}, | ||
_w[ConvertUnits.kgNH3N] = function (value) { return value * (N + H * 3) / N; }, | ||
_w), | ||
_a[ConvertUnits.kgNH4] = (_x = {}, | ||
_x[ConvertUnits.kgNH4N] = function (value) { return value * (N + H * 4) / N; }, | ||
_x), | ||
_a); | ||
@@ -45,0 +128,0 @@ var convertValue = function (n, fromUnit, toUnit, args) { |
{ | ||
"name": "@hestia-earth/utils", | ||
"version": "0.10.20", | ||
"version": "0.10.21", | ||
"description": "Hestia Utils library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33055
709