@configura/web-utilities 1.6.2 → 1.7.0
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/utilitiesUnits.js +13 -7
- package/package.json +2 -2
package/dist/utilitiesUnits.js
CHANGED
|
@@ -8,16 +8,17 @@ const meterPerFeet = meterPerInch * inchPerFeet;
|
|
|
8
8
|
* @throws an error if the supplied string isn't a known length unit
|
|
9
9
|
*/
|
|
10
10
|
export function toLengthUnit(unit) {
|
|
11
|
+
// The list below must EXACTLY match isLengthUnit(string)
|
|
11
12
|
unit = unit === null || unit === void 0 ? void 0 : unit.toLowerCase();
|
|
12
13
|
if (unit === "inch") {
|
|
13
14
|
unit = "in";
|
|
14
15
|
}
|
|
15
|
-
if (unit === "
|
|
16
|
+
if (unit === "in" ||
|
|
17
|
+
unit === "ft" ||
|
|
18
|
+
unit === "mm" ||
|
|
16
19
|
unit === "cm" ||
|
|
17
20
|
unit === "dm" ||
|
|
18
|
-
unit === "m"
|
|
19
|
-
unit === "in" ||
|
|
20
|
-
unit === "ft") {
|
|
21
|
+
unit === "m") {
|
|
21
22
|
return unit;
|
|
22
23
|
}
|
|
23
24
|
throw new Error(`Unknown length unit ${unit}`);
|
|
@@ -26,10 +27,15 @@ export function toLengthUnit(unit) {
|
|
|
26
27
|
* As we accept inch as an alias for in we can't make this a typeguard
|
|
27
28
|
*/
|
|
28
29
|
export function isLengthUnit(unit) {
|
|
29
|
-
|
|
30
|
+
// The list below must EXACTLY match toLengthUnit(string)
|
|
31
|
+
unit = unit === null || unit === void 0 ? void 0 : unit.toLowerCase();
|
|
32
|
+
return (unit === "inch" ||
|
|
30
33
|
unit === "in" ||
|
|
31
|
-
unit === "
|
|
32
|
-
unit === "
|
|
34
|
+
unit === "ft" ||
|
|
35
|
+
unit === "mm" ||
|
|
36
|
+
unit === "cm" ||
|
|
37
|
+
unit === "dm" ||
|
|
38
|
+
unit === "m");
|
|
33
39
|
}
|
|
34
40
|
export function convertLength(l, from, to) {
|
|
35
41
|
if (from === "ft" && to === "in") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/web-utilities",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "f6e1e62d91488535ef5b65eb93bbd69bdf1aabe7"
|
|
26
26
|
}
|