@darkpos/utils 1.0.12 → 1.0.14

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/lib/helpers.js CHANGED
@@ -84,6 +84,8 @@ const checkKey = (json, key) => {
84
84
  return true;
85
85
  };
86
86
 
87
+ const toNumberOrZero = value => (!value ? 0 : Number(value) || 0);
88
+
87
89
  //
88
90
  module.exports = {
89
91
  hasProperty,
@@ -101,4 +103,5 @@ module.exports = {
101
103
  mergeArrays,
102
104
  isArrayEqual,
103
105
  clearEmptyValues,
106
+ toNumberOrZero,
104
107
  };
@@ -1,6 +1,5 @@
1
1
  const { parsePhoneNumberFromString } = require('libphonenumber-js');
2
2
  const dateUtil = require('./date');
3
- const math = require('./math');
4
3
 
5
4
  const formats = {
6
5
  'en-US': 'MM/DD/YYYY',
@@ -168,7 +167,7 @@ const dateFormatPattern = lang => formats[lang];
168
167
  const monthAndDateFormatPattern = lang => monthAndDateFormats[lang];
169
168
 
170
169
  const formatAmountWithCurrency = (amount, currency, locale) =>
171
- typeof amount === 'number' || math.isNumber(amount)
170
+ typeof amount === 'number'
172
171
  ? new Intl.NumberFormat(locale, {
173
172
  style: 'currency',
174
173
  currency,
package/lib/math.js CHANGED
@@ -93,6 +93,8 @@ const min = (...args) => Decimal.min(...args).toNumber();
93
93
  const toNearestMultiple = (x, nearestMultiple) =>
94
94
  Decimal(x).toNearest(nearestMultiple, Decimal.ROUND_UP).toNumber();
95
95
 
96
+ const floor = x => Decimal.floor(x);
97
+
96
98
  module.exports = {
97
99
  mul,
98
100
  div,
@@ -110,4 +112,5 @@ module.exports = {
110
112
  max,
111
113
  min,
112
114
  toNearestMultiple,
115
+ floor,
113
116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/utils",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "General purpose utilities",
5
5
  "author": "Dark POS",
6
6
  "homepage": "https://gitlab.com/darkpos/packages/dark#readme",
@@ -33,11 +33,8 @@
33
33
  "eslint": "^8.2.0",
34
34
  "eslint-config-airbnb": "^19.0.4",
35
35
  "eslint-config-airbnb-base": "^15.0.0",
36
- "eslint-config-prettier": "^8.5.0",
37
36
  "eslint-plugin-import": "^2.26.0",
38
- "eslint-plugin-jest": "^26.5.3",
39
- "eslint-plugin-prettier": "^4.0.0",
40
- "prettier": "^2.7.0"
37
+ "eslint-plugin-jest": "^26.5.3"
41
38
  },
42
- "gitHead": "4e966b805abc74cc31cb0b3a0754e71f9bb913e5"
39
+ "gitHead": "40e27feaae9c0f473edce2c07aa9362a8a188d47"
43
40
  }