@oliasoft-open-source/units 4.3.0-beta-4 → 4.3.0-beta-5
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.d.ts +2 -36
- package/dist/units.d.ts +39 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
unit: string | never;
|
|
3
|
-
label: string | undefined;
|
|
4
|
-
}
|
|
5
|
-
interface ValidateReturn {
|
|
6
|
-
valid: boolean;
|
|
7
|
-
errors: (string | undefined)[] | undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
declare function showAltUnitsList(quantityKey: string): string[] | undefined;
|
|
11
|
-
declare function getUnitsForQuantity(quantity: string): string[] | undefined;
|
|
12
|
-
declare function getQuantities(): string[] | undefined;
|
|
13
|
-
declare function label(unitKey: string): string | undefined;
|
|
14
|
-
declare function unitFromKey(quantity: string): string | undefined;
|
|
15
|
-
declare function unitFromQuantity(quantity: string): string | undefined;
|
|
16
|
-
declare function getAltUnitsListByQuantity(quantity: string): AltUnitWithLabel[] | undefined;
|
|
17
|
-
declare function checkAndCleanDecimalComma(val: string | number): string | number;
|
|
18
|
-
declare function to(value: string | number, fromUnit: string, toUnit: string): number;
|
|
19
|
-
declare function split(numWithUnit: string): string[];
|
|
20
|
-
declare function getValue(numWithUnit: string): string;
|
|
21
|
-
declare function getUnit(numWithUnit: string): string;
|
|
22
|
-
declare function unum(numWithUnit: string | number, toUnit: string, fromUnit?: string): number;
|
|
23
|
-
declare function isValueWithUnit(value: string | number): boolean;
|
|
24
|
-
declare function convertAndGetValue(numWithUnit: string | number, toUnit: string, fromUnit?: string): number;
|
|
25
|
-
declare function convertAndGetValueStrict(value: string | number | null, toUnit: string, fromUnit?: string): string | number | null;
|
|
26
|
-
declare function toBase(value: string, quantity: string): number;
|
|
27
|
-
declare function convertTable(toUnitRow: any, table: any, defaultUnitRow?: [], removeFinalUnitsRow?: boolean): string | number[][];
|
|
28
|
-
declare function roundNumberWithLabel(value: string, n?: number): string;
|
|
29
|
-
declare function withUnit(value: string | number | null | undefined, unit: string | null, defaultVal?: string): string;
|
|
30
|
-
declare function unumWithUnit(numWithUnit: string | number, toUnit: string, fromUnit?: string): string;
|
|
31
|
-
declare function convertSamePrecision(numWithUnit: string | number, toUnit: string, digits?: number): string;
|
|
32
|
-
declare function altUnitsList(value: string, quantity: string): (string | undefined)[][];
|
|
33
|
-
declare function validateAndClean(previousValue: string, nextText: string): string;
|
|
34
|
-
declare function withPrettyUnitLabel(valueWithUnits: string): string;
|
|
35
|
-
declare function validateNumber(value: string | number): ValidateReturn;
|
|
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';
|
|
36
2
|
|
|
37
3
|
declare const LABELS: Record<string, string>;
|
|
38
4
|
declare const ALT_UNITS: Record<string, string[]>;
|
|
@@ -396,4 +362,4 @@ declare const isCloseToOrGreaterThan: (firstValue: number | string | null, secon
|
|
|
396
362
|
declare const isCloseToOrLessThan: (firstValue: number | string | null, secondValue: number | string | null, options?: toleranceType) => boolean;
|
|
397
363
|
declare const isDeepCloseTo: (a: any, b: any, options?: toleranceType) => boolean;
|
|
398
364
|
|
|
399
|
-
export { ALT_UNITS, DEPRECATED_UNITS, INTERMEDIATE_CONVERSIONS, KNOWN_CONVERSIONS, KNOWN_UNITS, LABELS, QUANTITIES_DESCRIPTION, UNITS_DESCRIPTION, UNIT_ALIASES, UNIT_FROM_KEY, allNumbers,
|
|
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, isScientificStringNum, isValidNum, numFraction, round, roundByMagnitude, roundByMagnitudeToFixed, roundByRange, roundToDecimalPrecision, roundToFixed, roundToPrecision, stripLeadingZeros, toNum, toString };
|
package/dist/units.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
interface AltUnitWithLabel {
|
|
2
|
+
unit: string | never;
|
|
3
|
+
label: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
interface ValidateReturn {
|
|
6
|
+
valid: boolean;
|
|
7
|
+
errors: (string | undefined)[] | undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const SEPARATOR = "|";
|
|
11
|
+
declare const EXP_NOTATION_RE: RegExp;
|
|
12
|
+
declare function showAltUnitsList(quantityKey: string): string[] | undefined;
|
|
13
|
+
declare function getUnitsForQuantity(quantity: string): string[] | undefined;
|
|
14
|
+
declare function getQuantities(): string[] | undefined;
|
|
15
|
+
declare function label(unitKey: string): string | undefined;
|
|
16
|
+
declare function unitFromKey(quantity: string): string | undefined;
|
|
17
|
+
declare function unitFromQuantity(quantity: string): string | undefined;
|
|
18
|
+
declare function getAltUnitsListByQuantity(quantity: string): AltUnitWithLabel[] | undefined;
|
|
19
|
+
declare function checkAndCleanDecimalComma(val: string | number): string | number;
|
|
20
|
+
declare function to(value: string | number, fromUnit: string, toUnit: string): number;
|
|
21
|
+
declare function split(numWithUnit: string): string[];
|
|
22
|
+
declare function getValue(numWithUnit: string): string;
|
|
23
|
+
declare function getUnit(numWithUnit: string): string;
|
|
24
|
+
declare function unum(numWithUnit: string | number, toUnit: string, fromUnit?: string): number;
|
|
25
|
+
declare function isValueWithUnit(value: string | number): boolean;
|
|
26
|
+
declare function convertAndGetValue(numWithUnit: string | number, toUnit: string, fromUnit?: string): number;
|
|
27
|
+
declare function convertAndGetValueStrict(value: string | number | null, toUnit: string, fromUnit?: string): string | number | null;
|
|
28
|
+
declare function toBase(value: string, quantity: string): number;
|
|
29
|
+
declare function convertTable(toUnitRow: any, table: any, defaultUnitRow?: [], removeFinalUnitsRow?: boolean): string | number[][];
|
|
30
|
+
declare function roundNumberWithLabel(value: string, n?: number): string;
|
|
31
|
+
declare function withUnit(value: string | number | null | undefined, unit: string | null, defaultVal?: string): string;
|
|
32
|
+
declare function unumWithUnit(numWithUnit: string | number, toUnit: string, fromUnit?: string): string;
|
|
33
|
+
declare function convertSamePrecision(numWithUnit: string | number, toUnit: string, digits?: number): string;
|
|
34
|
+
declare function altUnitsList(value: string, quantity: string): (string | undefined)[][];
|
|
35
|
+
declare function validateAndClean(previousValue: string, nextText: string): string;
|
|
36
|
+
declare function withPrettyUnitLabel(valueWithUnits: string): string;
|
|
37
|
+
declare function validateNumber(value: string | number): ValidateReturn;
|
|
38
|
+
|
|
39
|
+
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": "4.3.0-beta-
|
|
3
|
+
"version": "4.3.0-beta-5",
|
|
4
4
|
"description": "Package for units management",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"./dist/units": {
|
|
16
16
|
"import": "./dist/units.js",
|
|
17
|
-
"require": "./dist/units.cjs"
|
|
17
|
+
"require": "./dist/units.cjs",
|
|
18
|
+
"types": "./dist/units.d.ts"
|
|
18
19
|
}
|
|
19
20
|
},
|
|
20
21
|
"files": [
|