@my-devkit/core 1.0.83 → 1.0.85

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.
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
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"}
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
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
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -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,mCAAk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I,EAAJ,CAAI,EAAE,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;oBAE7G,cAAc,GAAG,IAAI,CAAC;oBACtB,UAAU,GAAG,CAAC,CAAC;;;;oBAGJ,qBAAM,SAAS,EAAE,EAAA;wBAAxB,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/dist/sleep.js CHANGED
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -1,21 +1,21 @@
1
1
  import { ListIteratee } from 'lodash';
2
- declare type List<T> = ArrayLike<T>;
3
- declare type ObjectIterator<TObject, TResult> = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult;
4
- declare type ObjectIteratee<TObject> = ObjectIterator<TObject, NotVoid> | IterateeShorthand<TObject[keyof TObject]>;
2
+ type List<T> = ArrayLike<T>;
3
+ type ObjectIterator<TObject, TResult> = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult;
4
+ type ObjectIteratee<TObject> = ObjectIterator<TObject, NotVoid> | IterateeShorthand<TObject[keyof TObject]>;
5
5
  interface Dictionary<T> {
6
6
  [index: string]: T;
7
7
  }
8
- declare type NotVoid = unknown;
9
- declare type PropertyName = string | number | symbol;
10
- declare type PartialShallow<T> = {
8
+ type NotVoid = unknown;
9
+ type PropertyName = string | number | symbol;
10
+ type PartialShallow<T> = {
11
11
  [P in keyof T]?: T[P] extends object ? object : T[P];
12
12
  };
13
- declare type IterateeShorthand<T> = PropertyName | [PropertyName, any] | PartialShallow<T>;
14
- declare type Many<T> = T | ReadonlyArray<T>;
15
- declare type ValueIteratee<T> = ((value: T) => NotVoid) | IterateeShorthand<T>;
16
- declare type RecursiveArray<T> = Array<T | RecursiveArray<T>>;
17
- declare type ListOfRecursiveArraysOrValues<T> = List<T | RecursiveArray<T>>;
18
- declare type Flat<T> = T extends string ? T : (T extends List<any> ? never : T);
13
+ type IterateeShorthand<T> = PropertyName | [PropertyName, any] | PartialShallow<T>;
14
+ type Many<T> = T | ReadonlyArray<T>;
15
+ type ValueIteratee<T> = ((value: T) => NotVoid) | IterateeShorthand<T>;
16
+ type RecursiveArray<T> = Array<T | RecursiveArray<T>>;
17
+ type ListOfRecursiveArraysOrValues<T> = List<T | RecursiveArray<T>>;
18
+ type Flat<T> = T extends string ? T : (T extends List<any> ? never : T);
19
19
  export declare const _uniq: <T>(array: List<T> | null | undefined) => T[];
20
20
  export declare const _flatten: <T>(array: List<Many<T>>) => T[];
21
21
  export declare const _flattenDeep: <T>(array: ListOfRecursiveArraysOrValues<T>) => Flat<T>[];
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.85",
4
4
  "description": "My Devkit: common tools",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "peerDependencies": {},
26
26
  "devDependencies": {
27
- "@my-devkit/cli": "1.0.22",
27
+ "@my-devkit/cli": "1.0.23",
28
28
  "@types/lodash": "4.14.173",
29
29
  "@types/node": "^14.14.19",
30
30
  "@typescript-eslint/eslint-plugin": "4.22.1",
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
  }