@oliasoft-open-source/units 5.5.2-beta-2 → 5.6.0-beta-4
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/{units2.cjs → chunks/conversion.cjs} +1711 -1998
- package/dist/chunks/conversion.cjs.map +1 -0
- package/dist/{units2.js → chunks/conversion.js} +1710 -1973
- package/dist/chunks/conversion.js.map +1 -0
- package/dist/{interfaces2.d.ts → chunks/types.d.cts} +2 -2
- package/dist/chunks/types.d.cts.map +1 -0
- package/dist/{interfaces2.d.cts → chunks/types.d.ts} +2 -2
- package/dist/chunks/types.d.ts.map +1 -0
- package/dist/chunks/units.cjs +55 -0
- package/dist/chunks/units.cjs.map +1 -0
- package/dist/chunks/units.d.cts +47 -0
- package/dist/chunks/units.d.cts.map +1 -0
- package/dist/chunks/units.d.ts +47 -0
- package/dist/chunks/units.d.ts.map +1 -0
- package/dist/chunks/units.js +38 -0
- package/dist/chunks/units.js.map +1 -0
- package/dist/index.cjs +91 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -20
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +25 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.cts +2 -2
- package/dist/interfaces.d.ts +2 -2
- package/dist/numbers/numbers.cjs +5 -5
- package/dist/numbers/numbers.d.cts.map +1 -1
- package/dist/numbers/numbers.d.ts.map +1 -1
- package/dist/numbers/numbers.js +1 -1
- package/dist/units.cjs +27 -26
- package/dist/units.d.cts +2 -34
- package/dist/units.d.ts +2 -34
- package/dist/units.js +2 -1
- package/package.json +6 -6
- package/dist/interfaces2.d.cts.map +0 -1
- package/dist/interfaces2.d.ts.map +0 -1
- package/dist/units.d.cts.map +0 -1
- package/dist/units.d.ts.map +0 -1
- package/dist/units2.cjs.map +0 -1
- package/dist/units2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
|
|
1
|
+
import { $ as showAltUnitsList, A as isNonNumerical, B as isEmptyValueWithUnit, C as roundToFixed, D as isCloseToOrLessThan, E as isCloseToOrGreaterThan, F as isFraction, G as charCount, H as split, I as numFraction, J as stripLeadingZeros, K as cleanNum, L as SEPARATOR, M as EXP_NOTATION_RE, N as asFraction, O as isDeepCloseTo, P as fraction, Q as label, R as getUnit, S as roundToDecimalPrecision, T as isCloseTo, U as withPrettyUnitLabel, V as isValueWithUnit, W as withUnit, X as getQuantities, Y as getAltUnitsListByQuantity, Z as getUnitsForQuantity, _ as formatNumber, a as toBase, at as KNOWN_CONVERSIONS, b as roundByMagnitudeToFixed, c as checkAndCleanDecimalComma, ct as QUANTITIES_DESCRIPTION, d as isScientificStringNum, dt as UNIT_FROM_KEY, et as unitFromKey, f as isValidNum, g as displayNumberToFixed, h as displayNumber, i as to, it as INTERMEDIATE_CONVERSIONS, j as isNumeric, k as allNumbers, l as validateAndClean, lt as UNITS_DESCRIPTION, m as toString, n as convertAndGetValueStrict, nt as ALT_UNITS, o as unum, ot as KNOWN_UNITS, p as toNum, q as cleanNumStr, r as convertSamePrecision, rt as DEPRECATED_UNITS, s as unumWithUnit, st as LABELS, t as convertAndGetValue, tt as unitFromQuantity, u as validateNumber, ut as UNIT_ALIASES, v as round, w as roundToPrecision, x as roundByRange, y as roundByMagnitude, z as getValue } from "./chunks/conversion.js";
|
|
2
|
+
import { n as roundNumberWithLabel, r as convertTable, t as altUnitsList } from "./chunks/units.js";
|
|
3
|
+
//#region src/numbers/rounding/number-digits.ts
|
|
4
|
+
/**
|
|
5
|
+
* Calculates a useful decimal precision for small values used by legacy rounding.
|
|
6
|
+
*
|
|
7
|
+
* @deprecated Use `roundByMagnitude` or another current rounding function instead.
|
|
8
|
+
*/
|
|
9
|
+
function getNumberOfDigitsToShow(value, maxNumberOfDigits = 20) {
|
|
10
|
+
const defaultDigits = Math.min(4, maxNumberOfDigits);
|
|
11
|
+
let digits = defaultDigits;
|
|
12
|
+
if (typeof value !== "number") return defaultDigits;
|
|
13
|
+
const valueString = String(value);
|
|
14
|
+
if (/-?[0-9.,]*[Ee]-?[0-9]+/.test(valueString)) {
|
|
15
|
+
while (Math.abs(value) * 10 ** digits < 1 && digits < maxNumberOfDigits) digits += 1;
|
|
16
|
+
return Math.min(digits + (defaultDigits - 1), maxNumberOfDigits);
|
|
17
|
+
}
|
|
18
|
+
if (value > 1 || value < -1) return defaultDigits;
|
|
19
|
+
for (let index = 2; index < valueString.length; index += 1) if (valueString[index] !== "0") return Math.min(maxNumberOfDigits, digits + index - 2);
|
|
20
|
+
return digits;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/numbers/rounding/cosmetic-rounding.ts
|
|
3
24
|
const COSMETIC_ROUNDING_DEFAULT_PRECISION = 14;
|
|
4
25
|
/**
|
|
5
26
|
* Applies display-only rounding to remove floating-point conversion noise.
|
|
@@ -25,6 +46,6 @@ const roundCosmetic = (value) => {
|
|
|
25
46
|
//#region src/index.ts
|
|
26
47
|
/* istanbul ignore file */
|
|
27
48
|
//#endregion
|
|
28
|
-
export { ALT_UNITS, DEPRECATED_UNITS, INTERMEDIATE_CONVERSIONS, KNOWN_CONVERSIONS, KNOWN_UNITS, LABELS, QUANTITIES_DESCRIPTION, UNITS_DESCRIPTION, UNIT_ALIASES, UNIT_FROM_KEY, allNumbers, altUnitsList, asFraction, charCount, checkAndCleanDecimalComma, cleanNum, cleanNumStr, convertAndGetValue, convertAndGetValueStrict, convertSamePrecision, convertTable, displayNumber, displayNumberToFixed, formatNumber, fraction, getAltUnitsListByQuantity, getNumberOfDigitsToShow, getQuantities, getUnit, getUnitsForQuantity, getValue, isCloseTo, isCloseToOrGreaterThan, isCloseToOrLessThan, isDeepCloseTo, isEmptyValueWithUnit, isFraction, isNonNumerical, isNumeric, isScientificStringNum, isValidNum, isValueWithUnit, label, numFraction, round, roundByMagnitude, roundByMagnitudeToFixed, roundByRange, roundCosmetic, roundNumberWithLabel, roundToDecimalPrecision, roundToFixed, roundToPrecision, showAltUnitsList, split, stripLeadingZeros, to, toBase, toNum, toString, unitFromKey, unitFromQuantity, unum, unumWithUnit, validateAndClean, validateNumber, withPrettyUnitLabel, withUnit };
|
|
49
|
+
export { ALT_UNITS, DEPRECATED_UNITS, EXP_NOTATION_RE, INTERMEDIATE_CONVERSIONS, KNOWN_CONVERSIONS, KNOWN_UNITS, LABELS, QUANTITIES_DESCRIPTION, SEPARATOR, UNITS_DESCRIPTION, UNIT_ALIASES, UNIT_FROM_KEY, allNumbers, altUnitsList, asFraction, charCount, checkAndCleanDecimalComma, cleanNum, cleanNumStr, convertAndGetValue, convertAndGetValueStrict, convertSamePrecision, convertTable, displayNumber, displayNumberToFixed, formatNumber, fraction, getAltUnitsListByQuantity, getNumberOfDigitsToShow, getQuantities, getUnit, getUnitsForQuantity, getValue, isCloseTo, isCloseToOrGreaterThan, isCloseToOrLessThan, isDeepCloseTo, isEmptyValueWithUnit, isFraction, isNonNumerical, isNumeric, isScientificStringNum, isValidNum, isValueWithUnit, label, numFraction, round, roundByMagnitude, roundByMagnitudeToFixed, roundByRange, roundCosmetic, roundNumberWithLabel, roundToDecimalPrecision, roundToFixed, roundToPrecision, showAltUnitsList, split, stripLeadingZeros, to, toBase, toNum, toString, unitFromKey, unitFromQuantity, unum, unumWithUnit, validateAndClean, validateNumber, withPrettyUnitLabel, withUnit };
|
|
29
50
|
|
|
30
51
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/rounding/cosmetic-rounding.ts","../src/index.ts"],"sourcesContent":["import { isScientificStringNum } from '../numbers
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/numbers/rounding/number-digits.ts","../src/numbers/rounding/cosmetic-rounding.ts","../src/index.ts"],"sourcesContent":["/**\n * Calculates a useful decimal precision for small values used by legacy rounding.\n *\n * @deprecated Use `roundByMagnitude` or another current rounding function instead.\n */\nexport function getNumberOfDigitsToShow(value: number | string, maxNumberOfDigits = 20): number {\n const defaultDigits = Math.min(4, maxNumberOfDigits);\n let digits = defaultDigits;\n if (typeof value !== 'number') {\n return defaultDigits;\n }\n\n const valueString = String(value);\n const exponentialNumber = /-?[0-9.,]*[Ee]-?[0-9]+/;\n if (exponentialNumber.test(valueString)) {\n while (Math.abs(value) * 10 ** digits < 1 && digits < maxNumberOfDigits) {\n digits += 1;\n }\n return Math.min(digits + (defaultDigits - 1), maxNumberOfDigits);\n }\n\n if (value > 1 || value < -1) {\n return defaultDigits;\n }\n\n for (let index = 2; index < valueString.length; index += 1) {\n if (valueString[index] !== '0') {\n return Math.min(maxNumberOfDigits, digits + index - 2);\n }\n }\n return digits;\n}\n","import { isScientificStringNum } from '../numbers.ts';\nimport { roundToPrecision } from './rounding.ts';\n\nconst COSMETIC_ROUNDING_DEFAULT_PRECISION = 14;\n\n/**\n * Applies display-only rounding to remove floating-point conversion noise.\n *\n * The value is rounded to 14 significant digits, while strings written in\n * scientific notation are preserved as entered.\n *\n * - accepts number types, stringified numbers, and unit strings\n * - returns the same type as the input\n *\n * @param value - numeric value to cosmetically round\n * @returns the cosmetically rounded value\n *\n * @example\n * roundCosmetic('9750.000000000004') -> '9750'\n * roundCosmetic('9750.000000000004|m') -> '9750|m'\n */\nexport const roundCosmetic = <Value extends number | string>(value: Value): Value => {\n if (isScientificStringNum(value)) {\n return value;\n }\n\n return roundToPrecision(value, COSMETIC_ROUNDING_DEFAULT_PRECISION);\n};\n","/* istanbul ignore file */\nimport {\n label,\n showAltUnitsList,\n getAltUnitsListByQuantity,\n checkAndCleanDecimalComma,\n unitFromKey,\n to,\n split,\n unum,\n toBase,\n altUnitsList,\n convertTable,\n roundNumberWithLabel,\n withUnit,\n unumWithUnit,\n validateAndClean,\n isValueWithUnit,\n getValue,\n getUnit,\n convertSamePrecision,\n convertAndGetValue,\n convertAndGetValueStrict,\n getUnitsForQuantity,\n getQuantities,\n unitFromQuantity,\n withPrettyUnitLabel,\n validateNumber,\n} from './units.ts';\nimport { isEmptyValueWithUnit } from './units/unit-string.ts';\n\nimport {\n ALT_UNITS,\n LABELS,\n UNIT_FROM_KEY,\n KNOWN_CONVERSIONS,\n DEPRECATED_UNITS,\n UNIT_ALIASES,\n INTERMEDIATE_CONVERSIONS,\n KNOWN_UNITS,\n QUANTITIES_DESCRIPTION,\n UNITS_DESCRIPTION,\n} from './units/constants.ts';\n\nimport { asFraction, fraction, isFraction, numFraction } from './numbers/fractions/fractions.ts';\nimport { charCount, cleanNum, cleanNumStr, stripLeadingZeros } from './numbers/parsing/number-input.ts';\nimport { allNumbers, isNonNumerical, isNumeric } from './numbers/predicates.ts';\nimport { getNumberOfDigitsToShow } from './numbers/rounding/number-digits.ts';\n\nimport { toNum, toString, isValidNum, isScientificStringNum } from './numbers/numbers.ts';\n\nimport { displayNumber, displayNumberToFixed, formatNumber } from './numbers/format/display-number.ts';\n\nimport {\n round,\n roundToFixed,\n roundToPrecision,\n roundToDecimalPrecision,\n roundByMagnitude,\n roundByMagnitudeToFixed,\n roundByRange,\n} from './numbers/rounding/rounding.ts';\n\nimport { roundCosmetic } from './numbers/rounding/cosmetic-rounding.ts';\n\nimport {\n isCloseTo,\n isCloseToOrGreaterThan,\n isCloseToOrLessThan,\n isDeepCloseTo,\n} from './numbers/comparison/comparison.ts';\n\nexport {\n // Units\n label,\n showAltUnitsList,\n getAltUnitsListByQuantity,\n getUnitsForQuantity,\n getQuantities,\n checkAndCleanDecimalComma,\n unitFromKey,\n unitFromQuantity,\n to,\n split,\n unum,\n toBase,\n altUnitsList,\n convertTable,\n roundNumberWithLabel,\n withUnit,\n unumWithUnit,\n validateAndClean,\n isValueWithUnit,\n getValue,\n getUnit,\n convertSamePrecision,\n convertAndGetValue,\n convertAndGetValueStrict,\n withPrettyUnitLabel,\n validateNumber,\n //Rounding\n round,\n roundToFixed,\n roundToPrecision,\n roundToDecimalPrecision,\n roundByMagnitude,\n roundByMagnitudeToFixed,\n roundByRange,\n roundCosmetic,\n //Comparison\n isCloseTo,\n isDeepCloseTo,\n isCloseToOrLessThan,\n isCloseToOrGreaterThan,\n // Utils\n isNumeric,\n isNonNumerical,\n isEmptyValueWithUnit,\n allNumbers,\n formatNumber,\n displayNumber,\n displayNumberToFixed,\n charCount,\n getNumberOfDigitsToShow,\n fraction,\n isFraction,\n asFraction,\n numFraction,\n cleanNumStr,\n cleanNum,\n toNum,\n toString,\n isValidNum,\n isScientificStringNum,\n stripLeadingZeros,\n // Constants\n ALT_UNITS,\n LABELS,\n UNIT_FROM_KEY,\n KNOWN_CONVERSIONS,\n DEPRECATED_UNITS,\n UNIT_ALIASES,\n INTERMEDIATE_CONVERSIONS,\n KNOWN_UNITS,\n QUANTITIES_DESCRIPTION,\n UNITS_DESCRIPTION,\n};\n\nexport { EXP_NOTATION_RE } from './numbers/scientific-notation/scientific-notation.ts';\nexport { SEPARATOR } from './units/unit-string.ts';\nexport type { AltUnitWithLabel, LocaleFormat, ValidateReturn } from './units/types.ts';\n"],"mappings":";;;;;;;;AAKA,SAAgB,wBAAwB,OAAwB,oBAAoB,IAAY;CAC9F,MAAM,gBAAgB,KAAK,IAAI,GAAG,kBAAkB;CACpD,IAAI,SAAS;AACb,KAAI,OAAO,UAAU,SACnB,QAAO;CAGT,MAAM,cAAc,OAAO,MAAM;AAEjC,KAD0B,yBACJ,KAAK,YAAY,EAAE;AACvC,SAAO,KAAK,IAAI,MAAM,GAAG,MAAM,SAAS,KAAK,SAAS,kBACpD,WAAU;AAEZ,SAAO,KAAK,IAAI,UAAU,gBAAgB,IAAI,kBAAkB;;AAGlE,KAAI,QAAQ,KAAK,QAAQ,GACvB,QAAO;AAGT,MAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,QAAQ,SAAS,EACvD,KAAI,YAAY,WAAW,IACzB,QAAO,KAAK,IAAI,mBAAmB,SAAS,QAAQ,EAAE;AAG1D,QAAO;;;;AC3BT,MAAM,sCAAsC;;;;;;;;;;;;;;;;;AAkB5C,MAAa,iBAAgD,UAAwB;AACnF,KAAI,sBAAsB,MAAM,CAC9B,QAAO;AAGT,QAAO,iBAAiB,OAAO,oCAAoC"}
|
package/dist/interfaces.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as LocaleFormat, r as ValidateReturn, t as AltUnitWithLabel } from "./
|
|
2
|
-
export { AltUnitWithLabel, LocaleFormat, ValidateReturn };
|
|
1
|
+
import { n as LocaleFormat, r as ValidateReturn, t as AltUnitWithLabel } from "./chunks/types.cjs";
|
|
2
|
+
export { type AltUnitWithLabel, type LocaleFormat, type ValidateReturn };
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as LocaleFormat, r as ValidateReturn, t as AltUnitWithLabel } from "./
|
|
2
|
-
export { AltUnitWithLabel, LocaleFormat, ValidateReturn };
|
|
1
|
+
import { n as LocaleFormat, r as ValidateReturn, t as AltUnitWithLabel } from "./chunks/types.js";
|
|
2
|
+
export { type AltUnitWithLabel, type LocaleFormat, type ValidateReturn };
|
package/dist/numbers/numbers.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
exports.isScientificStringNum =
|
|
4
|
-
exports.isValidNum =
|
|
5
|
-
exports.toNum =
|
|
6
|
-
exports.toString =
|
|
2
|
+
const require_conversion = require("../chunks/conversion.cjs");
|
|
3
|
+
exports.isScientificStringNum = require_conversion.isScientificStringNum;
|
|
4
|
+
exports.isValidNum = require_conversion.isValidNum;
|
|
5
|
+
exports.toNum = require_conversion.toNum;
|
|
6
|
+
exports.toString = require_conversion.toString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.cts","names":[],"sources":["../../src/numbers/numbers.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"numbers.d.cts","names":[],"sources":["../../src/numbers/numbers.ts"],"mappings":";cA+Ba,UAAA,GAAc,KAAA;AAAA,cA6Dd,qBAAA,GAAyB,KAAA;AAAA,cAsBzB,KAAA,GAAS,KAAA,WAAgB,QAAA,WAAmB,OAAA;AAAA,cA+B5C,QAAA,GAAY,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","names":[],"sources":["../../src/numbers/numbers.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","names":[],"sources":["../../src/numbers/numbers.ts"],"mappings":";cA+Ba,UAAA,GAAc,KAAA;AAAA,cA6Dd,qBAAA,GAAyB,KAAA;AAAA,cAsBzB,KAAA,GAAS,KAAA,WAAgB,QAAA,WAAmB,OAAA;AAAA,cA+B5C,QAAA,GAAY,KAAA"}
|
package/dist/numbers/numbers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as isScientificStringNum, f as isValidNum, m as toString, p as toNum } from "../chunks/conversion.js";
|
|
2
2
|
export { isScientificStringNum, isValidNum, toNum, toString };
|
package/dist/units.cjs
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
exports.
|
|
2
|
+
const require_conversion = require("./chunks/conversion.cjs");
|
|
3
|
+
const require_units = require("./chunks/units.cjs");
|
|
4
|
+
exports.EXP_NOTATION_RE = require_conversion.EXP_NOTATION_RE;
|
|
5
|
+
exports.SEPARATOR = require_conversion.SEPARATOR;
|
|
5
6
|
exports.altUnitsList = require_units.altUnitsList;
|
|
6
|
-
exports.checkAndCleanDecimalComma =
|
|
7
|
-
exports.convertAndGetValue =
|
|
8
|
-
exports.convertAndGetValueStrict =
|
|
9
|
-
exports.convertSamePrecision =
|
|
7
|
+
exports.checkAndCleanDecimalComma = require_conversion.checkAndCleanDecimalComma;
|
|
8
|
+
exports.convertAndGetValue = require_conversion.convertAndGetValue;
|
|
9
|
+
exports.convertAndGetValueStrict = require_conversion.convertAndGetValueStrict;
|
|
10
|
+
exports.convertSamePrecision = require_conversion.convertSamePrecision;
|
|
10
11
|
exports.convertTable = require_units.convertTable;
|
|
11
|
-
exports.getAltUnitsListByQuantity =
|
|
12
|
-
exports.getQuantities =
|
|
13
|
-
exports.getUnit =
|
|
14
|
-
exports.getUnitsForQuantity =
|
|
15
|
-
exports.getValue =
|
|
16
|
-
exports.isValueWithUnit =
|
|
17
|
-
exports.label =
|
|
12
|
+
exports.getAltUnitsListByQuantity = require_conversion.getAltUnitsListByQuantity;
|
|
13
|
+
exports.getQuantities = require_conversion.getQuantities;
|
|
14
|
+
exports.getUnit = require_conversion.getUnit;
|
|
15
|
+
exports.getUnitsForQuantity = require_conversion.getUnitsForQuantity;
|
|
16
|
+
exports.getValue = require_conversion.getValue;
|
|
17
|
+
exports.isValueWithUnit = require_conversion.isValueWithUnit;
|
|
18
|
+
exports.label = require_conversion.label;
|
|
18
19
|
exports.roundNumberWithLabel = require_units.roundNumberWithLabel;
|
|
19
|
-
exports.showAltUnitsList =
|
|
20
|
-
exports.split =
|
|
21
|
-
exports.to =
|
|
22
|
-
exports.toBase =
|
|
23
|
-
exports.unitFromKey =
|
|
24
|
-
exports.unitFromQuantity =
|
|
25
|
-
exports.unum =
|
|
26
|
-
exports.unumWithUnit =
|
|
27
|
-
exports.validateAndClean =
|
|
28
|
-
exports.validateNumber =
|
|
29
|
-
exports.withPrettyUnitLabel =
|
|
30
|
-
exports.withUnit =
|
|
20
|
+
exports.showAltUnitsList = require_conversion.showAltUnitsList;
|
|
21
|
+
exports.split = require_conversion.split;
|
|
22
|
+
exports.to = require_conversion.to;
|
|
23
|
+
exports.toBase = require_conversion.toBase;
|
|
24
|
+
exports.unitFromKey = require_conversion.unitFromKey;
|
|
25
|
+
exports.unitFromQuantity = require_conversion.unitFromQuantity;
|
|
26
|
+
exports.unum = require_conversion.unum;
|
|
27
|
+
exports.unumWithUnit = require_conversion.unumWithUnit;
|
|
28
|
+
exports.validateAndClean = require_conversion.validateAndClean;
|
|
29
|
+
exports.validateNumber = require_conversion.validateNumber;
|
|
30
|
+
exports.withPrettyUnitLabel = require_conversion.withPrettyUnitLabel;
|
|
31
|
+
exports.withUnit = require_conversion.withUnit;
|
package/dist/units.d.cts
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
import { r as
|
|
2
|
-
|
|
3
|
-
//#region src/units.d.ts
|
|
4
|
-
declare const SEPARATOR = "|";
|
|
5
|
-
declare const EXP_NOTATION_RE: RegExp;
|
|
6
|
-
declare function showAltUnitsList(quantityKey: string): string[] | undefined;
|
|
7
|
-
declare function getUnitsForQuantity(quantity: string): string[] | undefined;
|
|
8
|
-
declare function getQuantities(): string[] | undefined;
|
|
9
|
-
declare function label(unitKey: string): string | undefined;
|
|
10
|
-
declare function unitFromKey(quantity: string): string | undefined;
|
|
11
|
-
declare function unitFromQuantity(quantity: string): string | undefined;
|
|
12
|
-
declare function getAltUnitsListByQuantity(quantity: string): AltUnitWithLabel[] | undefined;
|
|
13
|
-
declare function checkAndCleanDecimalComma(val: string | number): string | number;
|
|
14
|
-
declare function to(value: string | number, fromUnit: string, toUnit: string): number;
|
|
15
|
-
declare function split(numWithUnit: string): string[];
|
|
16
|
-
declare function getValue(numWithUnit: string): string;
|
|
17
|
-
declare function getUnit(numWithUnit: string): string;
|
|
18
|
-
declare function unum(numWithUnit: string | number, toUnit: string, fromUnit?: string): number;
|
|
19
|
-
declare function isValueWithUnit(value: string | number): boolean;
|
|
20
|
-
declare function convertAndGetValue(numWithUnit: string | number, toUnit: string, fromUnit?: string): number;
|
|
21
|
-
declare function convertAndGetValueStrict(value: string | number | null, toUnit: string, fromUnit?: string): string | number | null;
|
|
22
|
-
declare function toBase(value: string, quantity: string): number;
|
|
23
|
-
declare function convertTable(toUnitRow: any, table: any, defaultUnitRow?: [], removeFinalUnitsRow?: boolean): string | number[][];
|
|
24
|
-
declare function roundNumberWithLabel(value: string, n?: number): string;
|
|
25
|
-
declare function withUnit(value: string | number | null | undefined, unit: string | null, defaultVal?: string): string;
|
|
26
|
-
declare function unumWithUnit(numWithUnit: string | number, toUnit: string, fromUnit?: string): string;
|
|
27
|
-
declare function convertSamePrecision(numWithUnit: string | number, toUnit: string, digits?: number): string;
|
|
28
|
-
declare function altUnitsList(value: string, quantity: string): (string | undefined)[][];
|
|
29
|
-
declare function validateAndClean(previousValue: string, nextText: string): string;
|
|
30
|
-
declare function withPrettyUnitLabel(valueWithUnits: string): string;
|
|
31
|
-
declare function validateNumber(value: string | number): ValidateReturn;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { EXP_NOTATION_RE, SEPARATOR, altUnitsList, checkAndCleanDecimalComma, convertAndGetValue, convertAndGetValueStrict, convertSamePrecision, convertTable, getAltUnitsListByQuantity, getQuantities, getUnit, getUnitsForQuantity, getValue, isValueWithUnit, label, roundNumberWithLabel, showAltUnitsList, split, to, toBase, unitFromKey, unitFromQuantity, unum, unumWithUnit, validateAndClean, validateNumber, withPrettyUnitLabel, withUnit };
|
|
34
|
-
//# sourceMappingURL=units.d.cts.map
|
|
1
|
+
import { C as getAltUnitsListByQuantity, D as showAltUnitsList, E as label, O as unitFromKey, S as withUnit, T as getUnitsForQuantity, _ as getValue, a as altUnitsList, b as split, c as convertAndGetValue, d as to, f as toBase, g as getUnit, h as SEPARATOR, i as validateNumber, k as unitFromQuantity, l as convertAndGetValueStrict, m as unumWithUnit, n as checkAndCleanDecimalComma, o as roundNumberWithLabel, p as unum, r as validateAndClean, s as convertTable, t as EXP_NOTATION_RE, u as convertSamePrecision, w as getQuantities, x as withPrettyUnitLabel, y as isValueWithUnit } from "./chunks/units.cjs";
|
|
2
|
+
export { EXP_NOTATION_RE, SEPARATOR, altUnitsList, checkAndCleanDecimalComma, convertAndGetValue, convertAndGetValueStrict, convertSamePrecision, convertTable, getAltUnitsListByQuantity, getQuantities, getUnit, getUnitsForQuantity, getValue, isValueWithUnit, label, roundNumberWithLabel, showAltUnitsList, split, to, toBase, unitFromKey, unitFromQuantity, unum, unumWithUnit, validateAndClean, validateNumber, withPrettyUnitLabel, withUnit };
|
package/dist/units.d.ts
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
import { r as
|
|
2
|
-
|
|
3
|
-
//#region src/units.d.ts
|
|
4
|
-
declare const SEPARATOR = "|";
|
|
5
|
-
declare const EXP_NOTATION_RE: RegExp;
|
|
6
|
-
declare function showAltUnitsList(quantityKey: string): string[] | undefined;
|
|
7
|
-
declare function getUnitsForQuantity(quantity: string): string[] | undefined;
|
|
8
|
-
declare function getQuantities(): string[] | undefined;
|
|
9
|
-
declare function label(unitKey: string): string | undefined;
|
|
10
|
-
declare function unitFromKey(quantity: string): string | undefined;
|
|
11
|
-
declare function unitFromQuantity(quantity: string): string | undefined;
|
|
12
|
-
declare function getAltUnitsListByQuantity(quantity: string): AltUnitWithLabel[] | undefined;
|
|
13
|
-
declare function checkAndCleanDecimalComma(val: string | number): string | number;
|
|
14
|
-
declare function to(value: string | number, fromUnit: string, toUnit: string): number;
|
|
15
|
-
declare function split(numWithUnit: string): string[];
|
|
16
|
-
declare function getValue(numWithUnit: string): string;
|
|
17
|
-
declare function getUnit(numWithUnit: string): string;
|
|
18
|
-
declare function unum(numWithUnit: string | number, toUnit: string, fromUnit?: string): number;
|
|
19
|
-
declare function isValueWithUnit(value: string | number): boolean;
|
|
20
|
-
declare function convertAndGetValue(numWithUnit: string | number, toUnit: string, fromUnit?: string): number;
|
|
21
|
-
declare function convertAndGetValueStrict(value: string | number | null, toUnit: string, fromUnit?: string): string | number | null;
|
|
22
|
-
declare function toBase(value: string, quantity: string): number;
|
|
23
|
-
declare function convertTable(toUnitRow: any, table: any, defaultUnitRow?: [], removeFinalUnitsRow?: boolean): string | number[][];
|
|
24
|
-
declare function roundNumberWithLabel(value: string, n?: number): string;
|
|
25
|
-
declare function withUnit(value: string | number | null | undefined, unit: string | null, defaultVal?: string): string;
|
|
26
|
-
declare function unumWithUnit(numWithUnit: string | number, toUnit: string, fromUnit?: string): string;
|
|
27
|
-
declare function convertSamePrecision(numWithUnit: string | number, toUnit: string, digits?: number): string;
|
|
28
|
-
declare function altUnitsList(value: string, quantity: string): (string | undefined)[][];
|
|
29
|
-
declare function validateAndClean(previousValue: string, nextText: string): string;
|
|
30
|
-
declare function withPrettyUnitLabel(valueWithUnits: string): string;
|
|
31
|
-
declare function validateNumber(value: string | number): ValidateReturn;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { EXP_NOTATION_RE, SEPARATOR, altUnitsList, checkAndCleanDecimalComma, convertAndGetValue, convertAndGetValueStrict, convertSamePrecision, convertTable, getAltUnitsListByQuantity, getQuantities, getUnit, getUnitsForQuantity, getValue, isValueWithUnit, label, roundNumberWithLabel, showAltUnitsList, split, to, toBase, unitFromKey, unitFromQuantity, unum, unumWithUnit, validateAndClean, validateNumber, withPrettyUnitLabel, withUnit };
|
|
34
|
-
//# sourceMappingURL=units.d.ts.map
|
|
1
|
+
import { C as getAltUnitsListByQuantity, D as showAltUnitsList, E as label, O as unitFromKey, S as withUnit, T as getUnitsForQuantity, _ as getValue, a as altUnitsList, b as split, c as convertAndGetValue, d as to, f as toBase, g as getUnit, h as SEPARATOR, i as validateNumber, k as unitFromQuantity, l as convertAndGetValueStrict, m as unumWithUnit, n as checkAndCleanDecimalComma, o as roundNumberWithLabel, p as unum, r as validateAndClean, s as convertTable, t as EXP_NOTATION_RE, u as convertSamePrecision, w as getQuantities, x as withPrettyUnitLabel, y as isValueWithUnit } from "./chunks/units.js";
|
|
2
|
+
export { EXP_NOTATION_RE, SEPARATOR, altUnitsList, checkAndCleanDecimalComma, convertAndGetValue, convertAndGetValueStrict, convertSamePrecision, convertTable, getAltUnitsListByQuantity, getQuantities, getUnit, getUnitsForQuantity, getValue, isValueWithUnit, label, roundNumberWithLabel, showAltUnitsList, split, to, toBase, unitFromKey, unitFromQuantity, unum, unumWithUnit, validateAndClean, validateNumber, withPrettyUnitLabel, withUnit };
|
package/dist/units.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as showAltUnitsList, H as split, L as SEPARATOR, M as EXP_NOTATION_RE, Q as label, R as getUnit, U as withPrettyUnitLabel, V as isValueWithUnit, W as withUnit, X as getQuantities, Y as getAltUnitsListByQuantity, Z as getUnitsForQuantity, a as toBase, c as checkAndCleanDecimalComma, et as unitFromKey, i as to, l as validateAndClean, n as convertAndGetValueStrict, o as unum, r as convertSamePrecision, s as unumWithUnit, t as convertAndGetValue, tt as unitFromQuantity, u as validateNumber, z as getValue } from "./chunks/conversion.js";
|
|
2
|
+
import { n as roundNumberWithLabel, r as convertTable, t as altUnitsList } from "./chunks/units.js";
|
|
2
3
|
export { EXP_NOTATION_RE, SEPARATOR, altUnitsList, checkAndCleanDecimalComma, convertAndGetValue, convertAndGetValueStrict, convertSamePrecision, convertTable, getAltUnitsListByQuantity, getQuantities, getUnit, getUnitsForQuantity, getValue, isValueWithUnit, label, roundNumberWithLabel, showAltUnitsList, split, to, toBase, unitFromKey, unitFromQuantity, unum, unumWithUnit, validateAndClean, validateNumber, withPrettyUnitLabel, withUnit };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/units",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0-beta-4",
|
|
4
4
|
"description": "Package for units management",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"tsdown": "^0.21.8",
|
|
109
109
|
"tsx": "^4.21.0",
|
|
110
110
|
"typescript": "^5.9.3",
|
|
111
|
-
"node": "runtime:26.
|
|
111
|
+
"node": "runtime:26.6.0"
|
|
112
112
|
},
|
|
113
113
|
"lint-staged": {
|
|
114
114
|
"*": [
|
|
@@ -119,12 +119,12 @@
|
|
|
119
119
|
"devEngines": {
|
|
120
120
|
"packageManager": {
|
|
121
121
|
"name": "pnpm",
|
|
122
|
-
"version": "11.
|
|
122
|
+
"version": "11.9.0",
|
|
123
123
|
"onFail": "download"
|
|
124
124
|
},
|
|
125
125
|
"runtime": {
|
|
126
126
|
"name": "node",
|
|
127
|
-
"version": "26.
|
|
127
|
+
"version": "26.6.0",
|
|
128
128
|
"onFail": "download"
|
|
129
129
|
}
|
|
130
130
|
},
|
|
@@ -139,8 +139,8 @@
|
|
|
139
139
|
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
140
140
|
"typecheck:scripts": "tsc -p tsconfig.scripts.json --noEmit",
|
|
141
141
|
"typecheck:build": "tsc -p tsconfig.build.json --noEmit",
|
|
142
|
-
"test": "pnpm format:check && pnpm compile-validators && pnpm run typecheck && pnpm run typecheck:scripts && node --import tsx --import ./test/setup.ts --test --experimental-test-coverage 'src/**/*.test.ts'
|
|
143
|
-
"test:watch": "node --watch --import tsx --import ./test/setup.ts --test 'src/**/*.test.ts'
|
|
142
|
+
"test": "pnpm format:check && pnpm compile-validators && pnpm run typecheck && pnpm run typecheck:scripts && node --import tsx --import ./test-setup/setup.ts --test --experimental-test-coverage 'src/**/*.test.ts'",
|
|
143
|
+
"test:watch": "node --watch --import tsx --import ./test-setup/setup.ts --test 'src/**/*.test.ts'",
|
|
144
144
|
"watch": "tsc -w -p tsconfig.dev.json",
|
|
145
145
|
"validate-release-notes": "node --import tsx scripts/validate-release-notes.ts",
|
|
146
146
|
"compile-validators": "node --import tsx scripts/compile-validators.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces2.d.cts","names":[],"sources":["../src/interfaces.ts"],"mappings":";UAAiB,gBAAA;EACf,IAAA;EACA,KAAA;AAAA;AAAA,UAGe,YAAA;EACf,SAAA;EACA,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,cAAA;EACf,KAAA;EACA,MAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces2.d.ts","names":[],"sources":["../src/interfaces.ts"],"mappings":";UAAiB,gBAAA;EACf,IAAA;EACA,KAAA;AAAA;AAAA,UAGe,YAAA;EACf,SAAA;EACA,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,cAAA;EACf,KAAA;EACA,MAAA;AAAA"}
|
package/dist/units.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.cts","names":[],"sources":["../src/units.ts"],"mappings":";;;cAmBa,SAAA;AAAA,cAEA,eAAA,EAAe,MAAA;AAAA,iBAQZ,gBAAA,CAAiB,WAAA;AAAA,iBAUjB,mBAAA,CAAoB,QAAA;AAAA,iBAQpB,aAAA,CAAA;AAAA,iBAUA,KAAA,CAAM,OAAA;AAAA,iBAUN,WAAA,CAAY,QAAA;AAAA,iBAUZ,gBAAA,CAAiB,QAAA;AAAA,iBAUjB,yBAAA,CAA0B,QAAA,WAAmB,gBAAA;AAAA,iBAY7C,yBAAA,CAA0B,GAAA;AAAA,iBAoB1B,EAAA,CAAG,KAAA,mBAAwB,QAAA,UAAkB,MAAA;AAAA,iBA8E7C,KAAA,CAAM,WAAA;AAAA,iBA4BN,QAAA,CAAS,WAAA;AAAA,iBAST,OAAA,CAAQ,WAAA;AAAA,iBAWR,IAAA,CAAK,WAAA,mBAA8B,MAAA,UAAgB,QAAA;AAAA,iBAmDnD,eAAA,CAAgB,KAAA;AAAA,iBAehB,kBAAA,CAAmB,WAAA,mBAA8B,MAAA,UAAgB,QAAA;AAAA,iBAYjE,wBAAA,CACd,KAAA,0BACA,MAAA,UACA,QAAA;AAAA,iBAoBc,MAAA,CAAO,KAAA,UAAe,QAAA;AAAA,iBAoBtB,YAAA,CACd,SAAA,OACA,KAAA,OACA,cAAA,OACA,mBAAA;AAAA,iBA0Cc,oBAAA,CAAqB,KAAA,UAAe,CAAA;AAAA,iBAYpC,QAAA,CAAS,KAAA,sCAA2C,IAAA,iBAAqB,UAAA;AAAA,iBAwBzE,YAAA,CAAa,WAAA,mBAA8B,MAAA,UAAgB,QAAA;AAAA,iBAa3D,oBAAA,CAAqB,WAAA,mBAA8B,MAAA,UAAgB,MAAA;AAAA,iBAiDnE,YAAA,CAAa,KAAA,UAAe,QAAA;AAAA,iBAmB5B,gBAAA,CAAiB,aAAA,UAAuB,QAAA;AAAA,iBAqCxC,mBAAA,CAAoB,cAAA;AAAA,iBAMpB,cAAA,CAAe,KAAA,oBAAyB,cAAA"}
|
package/dist/units.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.ts","names":[],"sources":["../src/units.ts"],"mappings":";;;cAmBa,SAAA;AAAA,cAEA,eAAA,EAAe,MAAA;AAAA,iBAQZ,gBAAA,CAAiB,WAAA;AAAA,iBAUjB,mBAAA,CAAoB,QAAA;AAAA,iBAQpB,aAAA,CAAA;AAAA,iBAUA,KAAA,CAAM,OAAA;AAAA,iBAUN,WAAA,CAAY,QAAA;AAAA,iBAUZ,gBAAA,CAAiB,QAAA;AAAA,iBAUjB,yBAAA,CAA0B,QAAA,WAAmB,gBAAA;AAAA,iBAY7C,yBAAA,CAA0B,GAAA;AAAA,iBAoB1B,EAAA,CAAG,KAAA,mBAAwB,QAAA,UAAkB,MAAA;AAAA,iBA8E7C,KAAA,CAAM,WAAA;AAAA,iBA4BN,QAAA,CAAS,WAAA;AAAA,iBAST,OAAA,CAAQ,WAAA;AAAA,iBAWR,IAAA,CAAK,WAAA,mBAA8B,MAAA,UAAgB,QAAA;AAAA,iBAmDnD,eAAA,CAAgB,KAAA;AAAA,iBAehB,kBAAA,CAAmB,WAAA,mBAA8B,MAAA,UAAgB,QAAA;AAAA,iBAYjE,wBAAA,CACd,KAAA,0BACA,MAAA,UACA,QAAA;AAAA,iBAoBc,MAAA,CAAO,KAAA,UAAe,QAAA;AAAA,iBAoBtB,YAAA,CACd,SAAA,OACA,KAAA,OACA,cAAA,OACA,mBAAA;AAAA,iBA0Cc,oBAAA,CAAqB,KAAA,UAAe,CAAA;AAAA,iBAYpC,QAAA,CAAS,KAAA,sCAA2C,IAAA,iBAAqB,UAAA;AAAA,iBAwBzE,YAAA,CAAa,WAAA,mBAA8B,MAAA,UAAgB,QAAA;AAAA,iBAa3D,oBAAA,CAAqB,WAAA,mBAA8B,MAAA,UAAgB,MAAA;AAAA,iBAiDnE,YAAA,CAAa,KAAA,UAAe,QAAA;AAAA,iBAmB5B,gBAAA,CAAiB,aAAA,UAAuB,QAAA;AAAA,iBAqCxC,mBAAA,CAAoB,cAAA;AAAA,iBAMpB,cAAA,CAAe,KAAA,oBAAyB,cAAA"}
|