@commercetools/connect-payments-sdk 0.17.1 → 0.18.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @commercetools/connect-payments-sdk
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1bd159b: feat(currency): add more unit-tests for currency convertions. Improve conversion logic.
8
+
9
+ ### Patch Changes
10
+
11
+ - 64ee10e: fix(dependency): explicitly add @eslint/js to devDependency to fix the lint related scripts
12
+
13
+ ## 0.17.2
14
+
15
+ ### Patch Changes
16
+
17
+ - e085f38: ci: create release using changeset
18
+
3
19
  ## 0.17.1
4
20
 
5
21
  ### Patch Changes
@@ -2,10 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertWithMapping = exports.convert = void 0;
4
4
  const validateFractionDigit = (fractionDigit) => {
5
- if (!Number.isInteger(fractionDigit)) {
5
+ if (!Number.isSafeInteger(fractionDigit)) {
6
6
  throw new Error(`The given fraction digit of "${fractionDigit}" is not a integer. Fraction digit must be an integer value.`);
7
7
  }
8
8
  };
9
+ const validateAmount = (amount) => {
10
+ if (!Number.isSafeInteger(amount)) {
11
+ throw new Error(`The given value of ${amount} is not a safe integer number`);
12
+ }
13
+ };
9
14
  /**
10
15
  * Applies the fraction digit to the given amount.
11
16
  * Positive fraction digit moves the decimal to the right, negative to the left. (i.e. adding or removing zeros from either end)
@@ -30,6 +35,7 @@ const validateFractionDigit = (fractionDigit) => {
30
35
  */
31
36
  const convert = (amount, fractionDigit) => {
32
37
  validateFractionDigit(fractionDigit);
38
+ validateAmount(amount);
33
39
  const result = amount * Math.pow(10, fractionDigit);
34
40
  const strResult = result.toFixed(Math.abs(fractionDigit));
35
41
  return parseFloat(strResult);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/connect-payments-sdk",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "description": "Payment SDK for commercetools payment connectors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",