@oliasoft-open-source/units 4.3.0-beta-5 → 4.3.1
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 +68 -68
- package/dist/index.d.ts +3 -6
- package/dist/interfaces.cjs +2 -0
- package/dist/interfaces.d.ts +15 -0
- package/dist/interfaces.js +1 -0
- package/dist/numbers/numbers.cjs +11 -0
- package/dist/numbers/numbers.d.ts +6 -0
- package/dist/numbers/numbers.js +2 -0
- package/dist/units.cjs +29 -29
- package/dist/units.d.ts +1 -8
- package/package.json +11 -1
package/dist/index.cjs
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var numbers = require('./units-8OgTPpkQ.cjs');
|
|
4
4
|
require('fraction.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.ALT_UNITS =
|
|
9
|
-
exports.DEPRECATED_UNITS =
|
|
10
|
-
exports.INTERMEDIATE_CONVERSIONS =
|
|
11
|
-
exports.KNOWN_CONVERSIONS =
|
|
12
|
-
exports.KNOWN_UNITS =
|
|
13
|
-
exports.LABELS =
|
|
14
|
-
exports.QUANTITIES_DESCRIPTION =
|
|
15
|
-
exports.UNITS_DESCRIPTION =
|
|
16
|
-
exports.UNIT_ALIASES =
|
|
17
|
-
exports.UNIT_FROM_KEY =
|
|
18
|
-
exports.allNumbers =
|
|
19
|
-
exports.altUnitsList =
|
|
20
|
-
exports.asFraction =
|
|
21
|
-
exports.charCount =
|
|
22
|
-
exports.checkAndCleanDecimalComma =
|
|
23
|
-
exports.cleanNum =
|
|
24
|
-
exports.cleanNumStr =
|
|
25
|
-
exports.convertAndGetValue =
|
|
26
|
-
exports.convertAndGetValueStrict =
|
|
27
|
-
exports.convertSamePrecision =
|
|
28
|
-
exports.convertTable =
|
|
29
|
-
exports.displayNumber =
|
|
30
|
-
exports.displayNumberToFixed =
|
|
31
|
-
exports.formatNumber =
|
|
32
|
-
exports.fraction =
|
|
33
|
-
exports.getAltUnitsListByQuantity =
|
|
34
|
-
exports.getNumberOfDigitsToShow =
|
|
35
|
-
exports.getQuantities =
|
|
36
|
-
exports.getUnit =
|
|
37
|
-
exports.getUnitsForQuantity =
|
|
38
|
-
exports.getValue =
|
|
39
|
-
exports.isCloseTo =
|
|
40
|
-
exports.isCloseToOrGreaterThan =
|
|
41
|
-
exports.isCloseToOrLessThan =
|
|
42
|
-
exports.isDeepCloseTo =
|
|
43
|
-
exports.isEmptyValueWithUnit =
|
|
44
|
-
exports.isFraction =
|
|
45
|
-
exports.isNonNumerical =
|
|
46
|
-
exports.isNumeric =
|
|
47
|
-
exports.isScientificStringNum =
|
|
48
|
-
exports.isValidNum =
|
|
49
|
-
exports.isValueWithUnit =
|
|
50
|
-
exports.label =
|
|
51
|
-
exports.numFraction =
|
|
52
|
-
exports.round =
|
|
53
|
-
exports.roundByMagnitude =
|
|
54
|
-
exports.roundByMagnitudeToFixed =
|
|
55
|
-
exports.roundByRange =
|
|
56
|
-
exports.roundNumberWithLabel =
|
|
57
|
-
exports.roundToDecimalPrecision =
|
|
58
|
-
exports.roundToFixed =
|
|
59
|
-
exports.roundToPrecision =
|
|
60
|
-
exports.showAltUnitsList =
|
|
61
|
-
exports.split =
|
|
62
|
-
exports.stripLeadingZeros =
|
|
63
|
-
exports.to =
|
|
64
|
-
exports.toBase =
|
|
65
|
-
exports.toNum =
|
|
66
|
-
exports.toString =
|
|
67
|
-
exports.unitFromKey =
|
|
68
|
-
exports.unitFromQuantity =
|
|
69
|
-
exports.unum =
|
|
70
|
-
exports.unumWithUnit =
|
|
71
|
-
exports.validateAndClean =
|
|
72
|
-
exports.validateNumber =
|
|
73
|
-
exports.withPrettyUnitLabel =
|
|
74
|
-
exports.withUnit =
|
|
8
|
+
exports.ALT_UNITS = numbers.ALT_UNITS;
|
|
9
|
+
exports.DEPRECATED_UNITS = numbers.DEPRECATED_UNITS;
|
|
10
|
+
exports.INTERMEDIATE_CONVERSIONS = numbers.INTERMEDIATE_CONVERSIONS;
|
|
11
|
+
exports.KNOWN_CONVERSIONS = numbers.KNOWN_CONVERSIONS;
|
|
12
|
+
exports.KNOWN_UNITS = numbers.KNOWN_UNITS;
|
|
13
|
+
exports.LABELS = numbers.LABELS;
|
|
14
|
+
exports.QUANTITIES_DESCRIPTION = numbers.QUANTITIES_DESCRIPTION;
|
|
15
|
+
exports.UNITS_DESCRIPTION = numbers.UNITS_DESCRIPTION;
|
|
16
|
+
exports.UNIT_ALIASES = numbers.UNIT_ALIASES;
|
|
17
|
+
exports.UNIT_FROM_KEY = numbers.UNIT_FROM_KEY;
|
|
18
|
+
exports.allNumbers = numbers.allNumbers;
|
|
19
|
+
exports.altUnitsList = numbers.altUnitsList;
|
|
20
|
+
exports.asFraction = numbers.asFraction;
|
|
21
|
+
exports.charCount = numbers.charCount;
|
|
22
|
+
exports.checkAndCleanDecimalComma = numbers.checkAndCleanDecimalComma;
|
|
23
|
+
exports.cleanNum = numbers.cleanNum;
|
|
24
|
+
exports.cleanNumStr = numbers.cleanNumStr;
|
|
25
|
+
exports.convertAndGetValue = numbers.convertAndGetValue;
|
|
26
|
+
exports.convertAndGetValueStrict = numbers.convertAndGetValueStrict;
|
|
27
|
+
exports.convertSamePrecision = numbers.convertSamePrecision;
|
|
28
|
+
exports.convertTable = numbers.convertTable;
|
|
29
|
+
exports.displayNumber = numbers.displayNumber;
|
|
30
|
+
exports.displayNumberToFixed = numbers.displayNumberToFixed;
|
|
31
|
+
exports.formatNumber = numbers.formatNumber;
|
|
32
|
+
exports.fraction = numbers.fraction;
|
|
33
|
+
exports.getAltUnitsListByQuantity = numbers.getAltUnitsListByQuantity;
|
|
34
|
+
exports.getNumberOfDigitsToShow = numbers.getNumberOfDigitsToShow;
|
|
35
|
+
exports.getQuantities = numbers.getQuantities;
|
|
36
|
+
exports.getUnit = numbers.getUnit;
|
|
37
|
+
exports.getUnitsForQuantity = numbers.getUnitsForQuantity;
|
|
38
|
+
exports.getValue = numbers.getValue;
|
|
39
|
+
exports.isCloseTo = numbers.isCloseTo;
|
|
40
|
+
exports.isCloseToOrGreaterThan = numbers.isCloseToOrGreaterThan;
|
|
41
|
+
exports.isCloseToOrLessThan = numbers.isCloseToOrLessThan;
|
|
42
|
+
exports.isDeepCloseTo = numbers.isDeepCloseTo;
|
|
43
|
+
exports.isEmptyValueWithUnit = numbers.isEmptyValueWithUnit;
|
|
44
|
+
exports.isFraction = numbers.isFraction;
|
|
45
|
+
exports.isNonNumerical = numbers.isNonNumerical;
|
|
46
|
+
exports.isNumeric = numbers.isNumeric;
|
|
47
|
+
exports.isScientificStringNum = numbers.isScientificStringNum;
|
|
48
|
+
exports.isValidNum = numbers.isValidNum;
|
|
49
|
+
exports.isValueWithUnit = numbers.isValueWithUnit;
|
|
50
|
+
exports.label = numbers.label;
|
|
51
|
+
exports.numFraction = numbers.numFraction;
|
|
52
|
+
exports.round = numbers.round;
|
|
53
|
+
exports.roundByMagnitude = numbers.roundByMagnitude;
|
|
54
|
+
exports.roundByMagnitudeToFixed = numbers.roundByMagnitudeToFixed;
|
|
55
|
+
exports.roundByRange = numbers.roundByRange;
|
|
56
|
+
exports.roundNumberWithLabel = numbers.roundNumberWithLabel;
|
|
57
|
+
exports.roundToDecimalPrecision = numbers.roundToDecimalPrecision;
|
|
58
|
+
exports.roundToFixed = numbers.roundToFixed;
|
|
59
|
+
exports.roundToPrecision = numbers.roundToPrecision;
|
|
60
|
+
exports.showAltUnitsList = numbers.showAltUnitsList;
|
|
61
|
+
exports.split = numbers.split;
|
|
62
|
+
exports.stripLeadingZeros = numbers.stripLeadingZeros;
|
|
63
|
+
exports.to = numbers.to;
|
|
64
|
+
exports.toBase = numbers.toBase;
|
|
65
|
+
exports.toNum = numbers.toNum;
|
|
66
|
+
exports.toString = numbers.toString;
|
|
67
|
+
exports.unitFromKey = numbers.unitFromKey;
|
|
68
|
+
exports.unitFromQuantity = numbers.unitFromQuantity;
|
|
69
|
+
exports.unum = numbers.unum;
|
|
70
|
+
exports.unumWithUnit = numbers.unumWithUnit;
|
|
71
|
+
exports.validateAndClean = numbers.validateAndClean;
|
|
72
|
+
exports.validateNumber = numbers.validateNumber;
|
|
73
|
+
exports.withPrettyUnitLabel = numbers.withPrettyUnitLabel;
|
|
74
|
+
exports.withUnit = numbers.withUnit;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { 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 } from './units.js';
|
|
2
|
+
export { isScientificStringNum, isValidNum, toNum, toString } from './numbers/numbers.js';
|
|
3
|
+
import './interfaces.js';
|
|
2
4
|
|
|
3
5
|
declare const LABELS: Record<string, string>;
|
|
4
6
|
declare const ALT_UNITS: Record<string, string[]>;
|
|
@@ -322,11 +324,6 @@ declare const stripLeadingZeros: (value: string) => string;
|
|
|
322
324
|
declare function cleanNum(str: string | number): number;
|
|
323
325
|
declare const isNonNumerical: (value: any) => boolean;
|
|
324
326
|
|
|
325
|
-
declare const isValidNum: (value: unknown) => boolean;
|
|
326
|
-
declare const isScientificStringNum: (value: unknown) => boolean;
|
|
327
|
-
declare const toNum: (value: unknown, fallback?: number, minimum?: number) => any;
|
|
328
|
-
declare const toString: (value?: unknown) => unknown;
|
|
329
|
-
|
|
330
327
|
type NumberDisplayOptions = {
|
|
331
328
|
scientific?: 'auto' | boolean;
|
|
332
329
|
eNotation?: boolean;
|
|
@@ -362,4 +359,4 @@ declare const isCloseToOrGreaterThan: (firstValue: number | string | null, secon
|
|
|
362
359
|
declare const isCloseToOrLessThan: (firstValue: number | string | null, secondValue: number | string | null, options?: toleranceType) => boolean;
|
|
363
360
|
declare const isDeepCloseTo: (a: any, b: any, options?: toleranceType) => boolean;
|
|
364
361
|
|
|
365
|
-
export { ALT_UNITS, DEPRECATED_UNITS, INTERMEDIATE_CONVERSIONS, KNOWN_CONVERSIONS, KNOWN_UNITS, LABELS, QUANTITIES_DESCRIPTION, UNITS_DESCRIPTION, UNIT_ALIASES, UNIT_FROM_KEY, allNumbers, asFraction, charCount, cleanNum, cleanNumStr, displayNumber, displayNumberToFixed, formatNumber, fraction, getNumberOfDigitsToShow, isCloseTo, isCloseToOrGreaterThan, isCloseToOrLessThan, isDeepCloseTo, isEmptyValueWithUnit, isFraction, isNonNumerical, isNumeric,
|
|
362
|
+
export { ALT_UNITS, DEPRECATED_UNITS, INTERMEDIATE_CONVERSIONS, KNOWN_CONVERSIONS, KNOWN_UNITS, LABELS, QUANTITIES_DESCRIPTION, UNITS_DESCRIPTION, UNIT_ALIASES, UNIT_FROM_KEY, allNumbers, asFraction, charCount, cleanNum, cleanNumStr, displayNumber, displayNumberToFixed, formatNumber, fraction, getNumberOfDigitsToShow, isCloseTo, isCloseToOrGreaterThan, isCloseToOrLessThan, isDeepCloseTo, isEmptyValueWithUnit, isFraction, isNonNumerical, isNumeric, numFraction, round, roundByMagnitude, roundByMagnitudeToFixed, roundByRange, roundToDecimalPrecision, roundToFixed, roundToPrecision, stripLeadingZeros };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface AltUnitWithLabel {
|
|
2
|
+
unit: string | never;
|
|
3
|
+
label: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
interface LocaleFormat {
|
|
6
|
+
thousands: string;
|
|
7
|
+
decimal: string;
|
|
8
|
+
useGrouping: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ValidateReturn {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
errors: (string | undefined)[] | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type { AltUnitWithLabel, LocaleFormat, ValidateReturn };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var numbers = require('../units-8OgTPpkQ.cjs');
|
|
4
|
+
require('fraction.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.isScientificStringNum = numbers.isScientificStringNum;
|
|
9
|
+
exports.isValidNum = numbers.isValidNum;
|
|
10
|
+
exports.toNum = numbers.toNum;
|
|
11
|
+
exports.toString = numbers.toString;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const isValidNum: (value: unknown) => boolean;
|
|
2
|
+
declare const isScientificStringNum: (value: unknown) => boolean;
|
|
3
|
+
declare const toNum: (value: unknown, fallback?: number, minimum?: number) => any;
|
|
4
|
+
declare const toString: (value?: unknown) => unknown;
|
|
5
|
+
|
|
6
|
+
export { isScientificStringNum, isValidNum, toNum, toString };
|
package/dist/units.cjs
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var numbers = require('./units-8OgTPpkQ.cjs');
|
|
4
4
|
require('fraction.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.EXP_NOTATION_RE =
|
|
9
|
-
exports.SEPARATOR =
|
|
10
|
-
exports.altUnitsList =
|
|
11
|
-
exports.checkAndCleanDecimalComma =
|
|
12
|
-
exports.convertAndGetValue =
|
|
13
|
-
exports.convertAndGetValueStrict =
|
|
14
|
-
exports.convertSamePrecision =
|
|
15
|
-
exports.convertTable =
|
|
16
|
-
exports.getAltUnitsListByQuantity =
|
|
17
|
-
exports.getQuantities =
|
|
18
|
-
exports.getUnit =
|
|
19
|
-
exports.getUnitsForQuantity =
|
|
20
|
-
exports.getValue =
|
|
21
|
-
exports.isValueWithUnit =
|
|
22
|
-
exports.label =
|
|
23
|
-
exports.roundNumberWithLabel =
|
|
24
|
-
exports.showAltUnitsList =
|
|
25
|
-
exports.split =
|
|
26
|
-
exports.to =
|
|
27
|
-
exports.toBase =
|
|
28
|
-
exports.unitFromKey =
|
|
29
|
-
exports.unitFromQuantity =
|
|
30
|
-
exports.unum =
|
|
31
|
-
exports.unumWithUnit =
|
|
32
|
-
exports.validateAndClean =
|
|
33
|
-
exports.validateNumber =
|
|
34
|
-
exports.withPrettyUnitLabel =
|
|
35
|
-
exports.withUnit =
|
|
8
|
+
exports.EXP_NOTATION_RE = numbers.EXP_NOTATION_RE;
|
|
9
|
+
exports.SEPARATOR = numbers.SEPARATOR;
|
|
10
|
+
exports.altUnitsList = numbers.altUnitsList;
|
|
11
|
+
exports.checkAndCleanDecimalComma = numbers.checkAndCleanDecimalComma;
|
|
12
|
+
exports.convertAndGetValue = numbers.convertAndGetValue;
|
|
13
|
+
exports.convertAndGetValueStrict = numbers.convertAndGetValueStrict;
|
|
14
|
+
exports.convertSamePrecision = numbers.convertSamePrecision;
|
|
15
|
+
exports.convertTable = numbers.convertTable;
|
|
16
|
+
exports.getAltUnitsListByQuantity = numbers.getAltUnitsListByQuantity;
|
|
17
|
+
exports.getQuantities = numbers.getQuantities;
|
|
18
|
+
exports.getUnit = numbers.getUnit;
|
|
19
|
+
exports.getUnitsForQuantity = numbers.getUnitsForQuantity;
|
|
20
|
+
exports.getValue = numbers.getValue;
|
|
21
|
+
exports.isValueWithUnit = numbers.isValueWithUnit;
|
|
22
|
+
exports.label = numbers.label;
|
|
23
|
+
exports.roundNumberWithLabel = numbers.roundNumberWithLabel;
|
|
24
|
+
exports.showAltUnitsList = numbers.showAltUnitsList;
|
|
25
|
+
exports.split = numbers.split;
|
|
26
|
+
exports.to = numbers.to;
|
|
27
|
+
exports.toBase = numbers.toBase;
|
|
28
|
+
exports.unitFromKey = numbers.unitFromKey;
|
|
29
|
+
exports.unitFromQuantity = numbers.unitFromQuantity;
|
|
30
|
+
exports.unum = numbers.unum;
|
|
31
|
+
exports.unumWithUnit = numbers.unumWithUnit;
|
|
32
|
+
exports.validateAndClean = numbers.validateAndClean;
|
|
33
|
+
exports.validateNumber = numbers.validateNumber;
|
|
34
|
+
exports.withPrettyUnitLabel = numbers.withPrettyUnitLabel;
|
|
35
|
+
exports.withUnit = numbers.withUnit;
|
package/dist/units.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
unit: string | never;
|
|
3
|
-
label: string | undefined;
|
|
4
|
-
}
|
|
5
|
-
interface ValidateReturn {
|
|
6
|
-
valid: boolean;
|
|
7
|
-
errors: (string | undefined)[] | undefined;
|
|
8
|
-
}
|
|
1
|
+
import { AltUnitWithLabel, ValidateReturn } from './interfaces.js';
|
|
9
2
|
|
|
10
3
|
declare const SEPARATOR = "|";
|
|
11
4
|
declare const EXP_NOTATION_RE: RegExp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/units",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "Package for units management",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,6 +16,16 @@
|
|
|
16
16
|
"import": "./dist/units.js",
|
|
17
17
|
"require": "./dist/units.cjs",
|
|
18
18
|
"types": "./dist/units.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./dist/numbers/numbers": {
|
|
21
|
+
"import": "./dist/numbers/numbers.js",
|
|
22
|
+
"require": "./dist/numbers/numbers.cjs",
|
|
23
|
+
"types": "./dist/numbers/numbers.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./dist/interfaces": {
|
|
26
|
+
"import": "./dist/interfaces.js",
|
|
27
|
+
"require": "./dist/interfaces.cjs",
|
|
28
|
+
"types": "./dist/interfaces.d.ts"
|
|
19
29
|
}
|
|
20
30
|
},
|
|
21
31
|
"files": [
|