@augment-vir/common 21.3.6 → 21.4.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/cjs/augments/number.js +7 -1
- package/dist/cjs/augments/object/matches-object-shape.js +2 -1
- package/dist/esm/augments/number.js +5 -0
- package/dist/esm/augments/object/matches-object-shape.js +2 -1
- package/dist/types/augments/number.d.ts +4 -0
- package/dist/types/augments/tuple.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapNumber = exports.toEnsuredNumber = void 0;
|
|
3
|
+
exports.round = exports.wrapNumber = exports.toEnsuredNumber = void 0;
|
|
4
4
|
function toEnsuredNumber(input) {
|
|
5
5
|
const numeric = Number(input);
|
|
6
6
|
if (isNaN(numeric)) {
|
|
@@ -21,3 +21,9 @@ function wrapNumber({ max, min, value }) {
|
|
|
21
21
|
return value;
|
|
22
22
|
}
|
|
23
23
|
exports.wrapNumber = wrapNumber;
|
|
24
|
+
function round(inputs) {
|
|
25
|
+
const digitFactor = Math.pow(10, inputs.digits);
|
|
26
|
+
const multiplied = inputs.number * digitFactor;
|
|
27
|
+
return Number((Math.round(multiplied) / digitFactor).toFixed(inputs.digits));
|
|
28
|
+
}
|
|
29
|
+
exports.round = round;
|
|
@@ -79,7 +79,8 @@ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps
|
|
|
79
79
|
if ((0, typed_has_property_1.typedHasProperty)(matchValue, 'constructor')) {
|
|
80
80
|
if (!(0, typed_has_property_1.typedHasProperty)(testValue, 'constructor') ||
|
|
81
81
|
testValue.constructor !== matchValue.constructor) {
|
|
82
|
-
throwKeyError(`constructor "${testValue?.constructor
|
|
82
|
+
throwKeyError(`constructor "${testValue?.constructor
|
|
83
|
+
?.name}" did not match expected constructor "${matchValue.constructor}"`);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -16,3 +16,8 @@ export function wrapNumber({ max, min, value }) {
|
|
|
16
16
|
}
|
|
17
17
|
return value;
|
|
18
18
|
}
|
|
19
|
+
export function round(inputs) {
|
|
20
|
+
const digitFactor = Math.pow(10, inputs.digits);
|
|
21
|
+
const multiplied = inputs.number * digitFactor;
|
|
22
|
+
return Number((Math.round(multiplied) / digitFactor).toFixed(inputs.digits));
|
|
23
|
+
}
|
|
@@ -74,7 +74,8 @@ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps
|
|
|
74
74
|
if (typedHasProperty(matchValue, 'constructor')) {
|
|
75
75
|
if (!typedHasProperty(testValue, 'constructor') ||
|
|
76
76
|
testValue.constructor !== matchValue.constructor) {
|
|
77
|
-
throwKeyError(`constructor "${testValue?.constructor
|
|
77
|
+
throwKeyError(`constructor "${testValue?.constructor
|
|
78
|
+
?.name}" did not match expected constructor "${matchValue.constructor}"`);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/common",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.4.0",
|
|
4
4
|
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/electrovir/augment-vir/issues"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"browser-or-node": "^2.1.1",
|
|
28
|
-
"type-fest": "^4.
|
|
28
|
+
"type-fest": "^4.6.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^5.2.2"
|