@8ms/helpers 1.6.0 → 1.6.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/number/getDecimal.d.ts +9 -0
- package/number/getDecimal.js +16 -0
- package/package.json +1 -1
- package/prisma/getDecimal.d.ts +1 -0
- package/prisma/getDecimal.js +8 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getNumber_1 = __importDefault(require("./getNumber"));
|
|
7
|
+
/**
|
|
8
|
+
* Return a decimal number after rounding.
|
|
9
|
+
*/
|
|
10
|
+
const getDecimal = (props) => {
|
|
11
|
+
const number = (0, getNumber_1.default)({
|
|
12
|
+
input: props.input,
|
|
13
|
+
});
|
|
14
|
+
return Number(number.toFixed(props?.dp || 2));
|
|
15
|
+
};
|
|
16
|
+
exports.default = getDecimal;
|
package/package.json
CHANGED
package/prisma/getDecimal.d.ts
CHANGED
package/prisma/getDecimal.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getDecimal_1 = __importDefault(require("../number/getDecimal"));
|
|
3
7
|
/**
|
|
4
8
|
* Fetch the number from a prisma decimal (comes through as an object).
|
|
5
9
|
*/
|
|
6
10
|
const getDecimal = (props) => {
|
|
7
11
|
let whole = props?.input?.d?.[0] || 0;
|
|
8
12
|
let decimal = props?.input?.d?.[1] || 0;
|
|
9
|
-
return
|
|
13
|
+
return (0, getDecimal_1.default)({
|
|
14
|
+
input: `${whole}.${decimal}`,
|
|
15
|
+
dp: props?.dp
|
|
16
|
+
});
|
|
10
17
|
};
|
|
11
18
|
exports.default = getDecimal;
|