@super-protocol/sdk-js 0.13.2 → 0.13.3

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.
@@ -38,24 +38,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.tryWithInterval = void 0;
40
40
  var tryWithInterval = function (params) { return __awaiter(void 0, void 0, void 0, function () {
41
- var interval, checkedTimes, handler, checkResult, checkError, retryInterval, retryMax, checkTimes;
41
+ var checkedTimes, handler, checkResult, checkError, retryInterval, retryMax;
42
42
  return __generator(this, function (_a) {
43
43
  switch (_a.label) {
44
44
  case 0:
45
- interval = null;
46
45
  checkedTimes = 0;
47
46
  handler = params.handler, checkResult = params.checkResult, checkError = params.checkError, retryInterval = params.retryInterval, retryMax = params.retryMax;
48
- checkTimes = function () {
49
- checkedTimes += 1;
50
- if (checkedTimes >= retryMax) {
51
- throw new Error("checkWithInterval: MaxCheck count reached!}");
52
- }
53
- };
54
- _a.label = 1;
55
- case 1:
56
- _a.trys.push([1, , 3, 4]);
57
47
  return [4 /*yield*/, new Promise(function (resolve, reject) {
58
- var intervalFn = function () { return __awaiter(void 0, void 0, void 0, function () {
48
+ var checkTimes = function () {
49
+ checkedTimes += 1;
50
+ if (checkedTimes >= retryMax) {
51
+ reject(new Error("checkWithInterval: MaxCheck count reached!}"));
52
+ }
53
+ else {
54
+ setTimeout(timeoutFn, retryInterval);
55
+ }
56
+ };
57
+ var timeoutFn = function () { return __awaiter(void 0, void 0, void 0, function () {
59
58
  var result, isResultOk, err_1, isErrorRetryable;
60
59
  return __generator(this, function (_a) {
61
60
  switch (_a.label) {
@@ -67,6 +66,7 @@ var tryWithInterval = function (params) { return __awaiter(void 0, void 0, void
67
66
  isResultOk = checkResult ? checkResult(result).isResultOk : true;
68
67
  if (isResultOk) {
69
68
  resolve(result);
69
+ return [2 /*return*/];
70
70
  }
71
71
  checkTimes();
72
72
  return [3 /*break*/, 3];
@@ -75,6 +75,7 @@ var tryWithInterval = function (params) { return __awaiter(void 0, void 0, void
75
75
  isErrorRetryable = checkError ? checkError(err_1).retryable : true;
76
76
  if (!isErrorRetryable) {
77
77
  reject(err_1);
78
+ return [2 /*return*/];
78
79
  }
79
80
  checkTimes();
80
81
  return [3 /*break*/, 3];
@@ -82,13 +83,9 @@ var tryWithInterval = function (params) { return __awaiter(void 0, void 0, void
82
83
  }
83
84
  });
84
85
  }); };
85
- interval = setInterval(intervalFn, retryInterval);
86
+ setTimeout(timeoutFn, retryInterval);
86
87
  })];
87
- case 2: return [2 /*return*/, _a.sent()];
88
- case 3:
89
- clearInterval(interval);
90
- return [7 /*endfinally*/];
91
- case 4: return [2 /*return*/];
88
+ case 1: return [2 /*return*/, _a.sent()];
92
89
  }
93
90
  });
94
91
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-protocol/sdk-js",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "main": "build/index.js",
5
5
  "license": "MIT",
6
6
  "files": [