@8ms/helpers 1.6.1 → 1.6.2

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.
@@ -1,9 +1,11 @@
1
- /**
2
- * Shorthand function to divide number, but fallback if the divisor is 0.
3
- */
4
- declare const getDivide: ({ defaultValue, divisor, numerator }: {
1
+ type GetDivide = {
5
2
  defaultValue?: number;
3
+ dp?: number;
6
4
  divisor: any;
7
5
  numerator: any;
8
- }) => number;
6
+ };
7
+ /**
8
+ * Shorthand function to divide number, but fallback if the divisor is 0.
9
+ */
10
+ declare const getDivide: (props: GetDivide) => number;
9
11
  export default getDivide;
@@ -4,19 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getNumber_1 = __importDefault(require("./getNumber"));
7
+ const getDecimal_1 = __importDefault(require("./getDecimal"));
7
8
  /**
8
9
  * Shorthand function to divide number, but fallback if the divisor is 0.
9
10
  */
10
- const getDivide = ({ defaultValue = 0, divisor, numerator }) => {
11
+ const getDivide = (props) => {
11
12
  const numeratorInt = (0, getNumber_1.default)({
12
- input: numerator
13
+ input: props.numerator
13
14
  });
14
15
  const divisorInt = (0, getNumber_1.default)({
15
- input: divisor
16
+ input: props.divisor
16
17
  });
17
18
  if (0 === divisorInt) {
18
- return defaultValue;
19
+ return props.defaultValue || 0;
19
20
  }
20
- return numeratorInt / divisorInt;
21
+ return (0, getDecimal_1.default)({
22
+ dp: props?.dp,
23
+ input: numeratorInt / divisorInt
24
+ });
21
25
  };
22
26
  exports.default = getDivide;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.6.1",
4
+ "version": "1.6.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"