@my-devkit/core 1.0.83 → 1.0.84

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/dist/index.d.ts CHANGED
@@ -15,5 +15,6 @@ export * from './serialize';
15
15
  export * from './retry';
16
16
  export * from './sleep';
17
17
  export * from './vendors';
18
+ export * from './promise-helper';
18
19
  export declare const Validators: typeof validators;
19
20
  export { ValidationError } from './validators/validation-error';
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ __exportStar(require("./serialize"), exports);
32
32
  __exportStar(require("./retry"), exports);
33
33
  __exportStar(require("./sleep"), exports);
34
34
  __exportStar(require("./vendors"), exports);
35
+ __exportStar(require("./promise-helper"), exports);
35
36
  exports.Validators = validators;
36
37
  var validation_error_1 = require("./validators/validation-error");
37
38
  Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validation_error_1.ValidationError; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAA2C;AAE3C,+CAA6B;AAC7B,6CAA2B;AAC3B,4CAA0B;AAC1B,0CAAwB;AACxB,gDAA8B;AAC9B,gDAA8B;AAC9B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AACxB,sDAAoC;AACpC,kDAAgC;AAChC,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AACb,QAAA,UAAU,GAAG,UAAU,CAAC;AACrC,kEAAgE;AAAvD,mHAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAA2C;AAE3C,+CAA6B;AAC7B,6CAA2B;AAC3B,4CAA0B;AAC1B,0CAAwB;AACxB,gDAA8B;AAC9B,gDAA8B;AAC9B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AACxB,sDAAoC;AACpC,kDAAgC;AAChC,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,mDAAiC;AAEpB,QAAA,UAAU,GAAG,UAAU,CAAC;AACrC,kEAAgE;AAAvD,mHAAA,eAAe,OAAA"}
package/dist/retry.d.ts CHANGED
@@ -12,5 +12,6 @@ export declare namespace retry {
12
12
  condition?: (error: any) => boolean;
13
13
  maxAttempts?: number;
14
14
  exponential?: boolean;
15
+ continueWithoutError?: boolean;
15
16
  }
16
17
  }
package/dist/retry.js CHANGED
@@ -61,7 +61,7 @@ function retry(operation, options) {
61
61
  return __generator(this, function (_a) {
62
62
  switch (_a.label) {
63
63
  case 0:
64
- options = __assign({ maxAttempts: 6, exponential: false, condition: function () { return true; } }, options);
64
+ options = __assign({ maxAttempts: 6, exponential: false, condition: function () { return true; }, continueWithoutError: false }, options);
65
65
  continueTrying = true;
66
66
  retryCount = 0;
67
67
  _a.label = 1;
@@ -72,7 +72,10 @@ function retry(operation, options) {
72
72
  case 3:
73
73
  e_1 = _a.sent();
74
74
  continueTrying = retryCount < options.maxAttempts && options.condition(e_1);
75
- if (!continueTrying) {
75
+ if (!continueTrying && options.continueWithoutError) {
76
+ return [2 /*return*/];
77
+ }
78
+ if (!continueTrying && !options.continueWithoutError) {
76
79
  throw e_1;
77
80
  }
78
81
  if (!options.exponential) return [3 /*break*/, 5];
package/dist/retry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAClC,iCAAgC;AAEhC;;;;GAIG;AACH,SAAsB,KAAK,CAAI,SAA2B,EAAE,OAAuB;;;;;;oBAC/E,OAAO,cAAK,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,cAA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BAAxB,sBAAO,SAAiB,EAAC;;;oBAEzB,cAAc,GAAG,UAAU,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC,GAAC,CAAC,CAAC;oBAC1E,IAAI,CAAC,cAAc,IAAI,OAAO,CAAC,oBAAoB,EAAE;wBACjD,sBAAO;qBACV;oBACD,IAAI,CAAC,cAAc,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;wBAClD,MAAM,GAAC,CAAC;qBACX;yBACG,OAAO,CAAC,WAAW,EAAnB,wBAAmB;oBACnB,qBAAM,IAAA,aAAK,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,EAAA;;oBAA9E,SAA8E,CAAC;;;oBAGnF,UAAU,EAAE,CAAC;oBACb,eAAM,CAAC,IAAI,CAAC,6BAAsB,UAAU,cAAI,OAAO,CAAC,WAAW,CAAE,CAAC,CAAC;;;wBAEtE,cAAc;;;;;;CAC1B;AAxBD,sBAwBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@my-devkit/core",
3
- "version": "1.0.83",
3
+ "version": "1.0.84",
4
4
  "description": "My Devkit: common tools",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -16,5 +16,7 @@ export * from './serialize';
16
16
  export * from './retry';
17
17
  export * from './sleep';
18
18
  export * from './vendors';
19
+ export * from './promise-helper';
20
+
19
21
  export const Validators = validators;
20
22
  export { ValidationError } from './validators/validation-error';
package/src/retry.ts CHANGED
@@ -7,7 +7,7 @@ import { sleep } from './sleep';
7
7
  * @param options
8
8
  */
9
9
  export async function retry<T>(operation: () => Promise<T>, options?: retry.Options): Promise<T> {
10
- options = { maxAttempts: 6, exponential: false, condition: () => true, ...options };
10
+ options = { maxAttempts: 6, exponential: false, condition: () => true, continueWithoutError: false, ...options };
11
11
 
12
12
  let continueTrying = true;
13
13
  let retryCount = 0;
@@ -16,7 +16,10 @@ export async function retry<T>(operation: () => Promise<T>, options?: retry.Opti
16
16
  return await operation();
17
17
  } catch (e) {
18
18
  continueTrying = retryCount < options.maxAttempts && options.condition(e);
19
- if (!continueTrying) {
19
+ if (!continueTrying && options.continueWithoutError) {
20
+ return;
21
+ }
22
+ if (!continueTrying && !options.continueWithoutError) {
20
23
  throw e;
21
24
  }
22
25
  if (options.exponential) {
@@ -37,5 +40,6 @@ export namespace retry {
37
40
  condition?: (error: any) => boolean;
38
41
  maxAttempts?: number;
39
42
  exponential?: boolean;
43
+ continueWithoutError?: boolean;
40
44
  }
41
45
  }