@willbooster/shared-lib 3.0.0 → 3.1.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.
@@ -1,2 +1,2 @@
1
- "use strict";exports.ignoreEnoent=function(t){try{return t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}},exports.ignoreEnoentAsync=async function(t){try{return await t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}},exports.ignoreError=function(t){try{return t()}catch(t){}},exports.ignoreErrorAsync=async function(t){try{return await t()}catch(t){}};
1
+ "use strict";exports.ignoreEnoent=function(t){try{return t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}},exports.ignoreEnoentAsync=async function(t){try{return await t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}},exports.ignoreError=function(t){try{return t()}catch(t){}},exports.ignoreErrorAsync=async function(t){try{return await t()}catch(t){}},exports.withRetry=async function(t,r=3,n){let o=0;for(;;)try{return await t()}catch(t){if(o++,o>=r)throw t;null==n||n(`Retry due to: ${t instanceof Error?t.stack:t}`)}};
2
2
  //# sourceMappingURL=error.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.cjs","sources":["../../src/error.ts"],"sourcesContent":["export function ignoreError<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch {\n // do nothing\n }\n}\n\nexport function ignoreEnoent<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch (error) {\n if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n\nexport async function ignoreErrorAsync<T>(fn: () => Promise<T>): Promise<T | undefined> {\n try {\n return await fn();\n } catch {\n // do nothing\n }\n}\n\nexport async function ignoreEnoentAsync<T>(fn: () => Promise<T>): Promise<T | undefined> {\n try {\n return await fn();\n } catch (error) {\n if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n"],"names":["fn","error","code","async","_unused","_unused2"],"mappings":"kCAQO,SAAyBA,GAC9B,IACE,OAAOA,GACR,CAAC,MAAOC,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,4BAUOE,eAAoCH,GACzC,IACE,aAAaA,GACd,CAAC,MAAOC,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,sBApCO,SAAwBD,GAC7B,IACE,OAAOA,GACR,CAAC,MAAAI,GACA,CAEJ,2BAaOD,eAAmCH,GACxC,IACE,aAAaA,GACd,CAAC,MAAAK,GACA,CAEJ"}
1
+ {"version":3,"file":"error.cjs","sources":["../../src/error.ts"],"sourcesContent":["export function ignoreError<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch {\n // do nothing\n }\n}\n\nexport function ignoreEnoent<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch (error) {\n if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n\nexport async function ignoreErrorAsync<T>(fn: () => Promise<T>): Promise<T | undefined> {\n try {\n return await fn();\n } catch {\n // do nothing\n }\n}\n\nexport async function ignoreEnoentAsync<T>(fn: () => Promise<T>): Promise<T | undefined> {\n try {\n return await fn();\n } catch (error) {\n if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n\nexport async function withRetry<T>(\n func: () => Promise<T>,\n retryCount = 3,\n log?: (message: string) => void\n): Promise<T> {\n let failedCount = 0;\n for (;;) {\n try {\n return await func();\n } catch (error) {\n failedCount++;\n if (failedCount >= retryCount) {\n throw error;\n }\n log?.(`Retry due to: ${error instanceof Error ? error.stack : error}`);\n }\n }\n}\n"],"names":["fn","error","code","async","_unused","_unused2","func","retryCount","log","failedCount","Error","stack"],"mappings":"kCAQO,SAAyBA,GAC9B,IACE,OAAOA,GACR,CAAC,MAAOC,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,4BAUOE,eAAoCH,GACzC,IACE,aAAaA,GACd,CAAC,MAAOC,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,sBApCO,SAAwBD,GAC7B,IACE,OAAOA,GACR,CAAC,MAAAI,GACA,CAEJ,2BAaOD,eAAmCH,GACxC,IACE,aAAaA,GACd,CAAC,MAAAK,GACA,CAEJ,oBAaOF,eACLG,EACAC,EAAa,EACbC,GAEA,IAAIC,EAAc,EAClB,OACE,IACE,aAAaH,GACd,CAAC,MAAOL,GAEP,GADAQ,IACIA,GAAeF,EACjB,MAAMN,EAERO,SAAAA,EAAO,iBAAgBP,aAAiBS,MAAQT,EAAMU,MAAQV,IAChE,CAEJ"}
@@ -2,4 +2,5 @@ declare function ignoreError<T>(fn: () => T): T | undefined;
2
2
  declare function ignoreEnoent<T>(fn: () => T): T | undefined;
3
3
  declare function ignoreErrorAsync<T>(fn: () => Promise<T>): Promise<T | undefined>;
4
4
  declare function ignoreEnoentAsync<T>(fn: () => Promise<T>): Promise<T | undefined>;
5
- export { ignoreError, ignoreEnoent, ignoreErrorAsync, ignoreEnoentAsync };
5
+ declare function withRetry<T>(func: () => Promise<T>, retryCount?: number, log?: (message: string) => void): Promise<T>;
6
+ export { ignoreError, ignoreEnoent, ignoreErrorAsync, ignoreEnoentAsync, withRetry };
@@ -1,2 +1,2 @@
1
- "use strict";var r=require("./error.cjs"),e=require("./shuffle.cjs"),n=require("./zenkaku.cjs");exports.ignoreEnoent=r.ignoreEnoent,exports.ignoreEnoentAsync=r.ignoreEnoentAsync,exports.ignoreError=r.ignoreError,exports.ignoreErrorAsync=r.ignoreErrorAsync,exports.shuffle=e.shuffle,exports.zenkakuAlphanumericalsToHankaku=n.zenkakuAlphanumericalsToHankaku;
1
+ "use strict";var r=require("./error.cjs"),e=require("./shuffle.cjs"),n=require("./zenkaku.cjs");exports.ignoreEnoent=r.ignoreEnoent,exports.ignoreEnoentAsync=r.ignoreEnoentAsync,exports.ignoreError=r.ignoreError,exports.ignoreErrorAsync=r.ignoreErrorAsync,exports.withRetry=r.withRetry,exports.shuffle=e.shuffle,exports.zenkakuAlphanumericalsToHankaku=n.zenkakuAlphanumericalsToHankaku;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,3 +1,3 @@
1
- export { ignoreError, ignoreEnoent, ignoreErrorAsync, ignoreEnoentAsync } from "./error.js";
1
+ export { ignoreError, ignoreEnoent, ignoreErrorAsync, ignoreEnoentAsync, withRetry } from "./error.js";
2
2
  export { shuffle } from "./shuffle.js";
3
3
  export { zenkakuAlphanumericalsToHankaku } from "./zenkaku.js";
@@ -1,2 +1,2 @@
1
- "use strict";exports.zenkakuAlphanumericalsToHankaku=function(n){return n.replace(/[0-9A-Za-z]/g,(n=>{var r;return String.fromCodePoint((null!==(r=n.codePointAt(0))&&void 0!==r?r:0)-65248)}))};
1
+ "use strict";exports.zenkakuAlphanumericalsToHankaku=function(n){return n.replaceAll(/[0-9A-Za-z]/g,(n=>{var r;return String.fromCodePoint((null!==(r=n.codePointAt(0))&&void 0!==r?r:0)-65248)}))};
2
2
  //# sourceMappingURL=zenkaku.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"zenkaku.cjs","sources":["../../src/zenkaku.ts"],"sourcesContent":["export function zenkakuAlphanumericalsToHankaku(str: string): string {\n return str.replace(/[0-9A-Za-z]/g, (s: string) => {\n return String.fromCodePoint((s.codePointAt(0) ?? 0) - 0xfe_e0);\n });\n}\n"],"names":["str","replace","s","_s$codePointAt","String","fromCodePoint","codePointAt"],"mappings":"qDAAO,SAAyCA,GAC9C,OAAOA,EAAIC,QAAQ,gBAAiBC,IAAc,IAAAC,EAChD,OAAOC,OAAOC,uBAAcF,EAACD,EAAEI,YAAY,UAAE,IAAAH,EAAAA,EAAI,GAAK,MAAQ,GAElE"}
1
+ {"version":3,"file":"zenkaku.cjs","sources":["../../src/zenkaku.ts"],"sourcesContent":["export function zenkakuAlphanumericalsToHankaku(str: string): string {\n return str.replaceAll(/[0-9A-Za-z]/g, (s: string) => {\n return String.fromCodePoint((s.codePointAt(0) ?? 0) - 0xfe_e0);\n });\n}\n"],"names":["str","replaceAll","s","_s$codePointAt","String","fromCodePoint","codePointAt"],"mappings":"qDAAO,SAAyCA,GAC9C,OAAOA,EAAIC,WAAW,gBAAiBC,IAAc,IAAAC,EACnD,OAAOC,OAAOC,uBAAcF,EAACD,EAAEI,YAAY,UAAE,IAAAH,EAAAA,EAAI,GAAK,MAAQ,GAElE"}
@@ -2,4 +2,5 @@ declare function ignoreError<T>(fn: () => T): T | undefined;
2
2
  declare function ignoreEnoent<T>(fn: () => T): T | undefined;
3
3
  declare function ignoreErrorAsync<T>(fn: () => Promise<T>): Promise<T | undefined>;
4
4
  declare function ignoreEnoentAsync<T>(fn: () => Promise<T>): Promise<T | undefined>;
5
- export { ignoreError, ignoreEnoent, ignoreErrorAsync, ignoreEnoentAsync };
5
+ declare function withRetry<T>(func: () => Promise<T>, retryCount?: number, log?: (message: string) => void): Promise<T>;
6
+ export { ignoreError, ignoreEnoent, ignoreErrorAsync, ignoreEnoentAsync, withRetry };
package/dist/esm/error.js CHANGED
@@ -1,2 +1,2 @@
1
- function t(t){try{return t()}catch(t){}}function c(t){try{return t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}}async function r(t){try{return await t()}catch(t){}}async function n(t){try{return await t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}}export{c as ignoreEnoent,n as ignoreEnoentAsync,t as ignoreError,r as ignoreErrorAsync};
1
+ function t(t){try{return t()}catch(t){}}function r(t){try{return t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}}async function c(t){try{return await t()}catch(t){}}async function n(t){try{return await t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}}async function o(t,r=3,c){let n=0;for(;;)try{return await t()}catch(t){if(n++,n>=r)throw t;null==c||c(`Retry due to: ${t instanceof Error?t.stack:t}`)}}export{r as ignoreEnoent,n as ignoreEnoentAsync,t as ignoreError,c as ignoreErrorAsync,o as withRetry};
2
2
  //# sourceMappingURL=error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sources":["../../src/error.ts"],"sourcesContent":["export function ignoreError<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch {\n // do nothing\n }\n}\n\nexport function ignoreEnoent<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch (error) {\n if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n\nexport async function ignoreErrorAsync<T>(fn: () => Promise<T>): Promise<T | undefined> {\n try {\n return await fn();\n } catch {\n // do nothing\n }\n}\n\nexport async function ignoreEnoentAsync<T>(fn: () => Promise<T>): Promise<T | undefined> {\n try {\n return await fn();\n } catch (error) {\n if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n"],"names":["ignoreError","fn","_unused","ignoreEnoent","error","code","async","ignoreErrorAsync","_unused2","ignoreEnoentAsync"],"mappings":"AAAO,SAASA,EAAeC,GAC7B,IACE,OAAOA,GACR,CAAC,MAAAC,GACA,CAEJ,CAEO,SAASC,EAAgBF,GAC9B,IACE,OAAOA,GACR,CAAC,MAAOG,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,CAEOE,eAAeC,EAAoBN,GACxC,IACE,aAAaA,GACd,CAAC,MAAAO,GACA,CAEJ,CAEOF,eAAeG,EAAqBR,GACzC,IACE,aAAaA,GACd,CAAC,MAAOG,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF"}
1
+ {"version":3,"file":"error.js","sources":["../../src/error.ts"],"sourcesContent":["export function ignoreError<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch {\n // do nothing\n }\n}\n\nexport function ignoreEnoent<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch (error) {\n if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n\nexport async function ignoreErrorAsync<T>(fn: () => Promise<T>): Promise<T | undefined> {\n try {\n return await fn();\n } catch {\n // do nothing\n }\n}\n\nexport async function ignoreEnoentAsync<T>(fn: () => Promise<T>): Promise<T | undefined> {\n try {\n return await fn();\n } catch (error) {\n if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n\nexport async function withRetry<T>(\n func: () => Promise<T>,\n retryCount = 3,\n log?: (message: string) => void\n): Promise<T> {\n let failedCount = 0;\n for (;;) {\n try {\n return await func();\n } catch (error) {\n failedCount++;\n if (failedCount >= retryCount) {\n throw error;\n }\n log?.(`Retry due to: ${error instanceof Error ? error.stack : error}`);\n }\n }\n}\n"],"names":["ignoreError","fn","_unused","ignoreEnoent","error","code","async","ignoreErrorAsync","_unused2","ignoreEnoentAsync","withRetry","func","retryCount","log","failedCount","Error","stack"],"mappings":"AAAO,SAASA,EAAeC,GAC7B,IACE,OAAOA,GACR,CAAC,MAAAC,GACA,CAEJ,CAEO,SAASC,EAAgBF,GAC9B,IACE,OAAOA,GACR,CAAC,MAAOG,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,CAEOE,eAAeC,EAAoBN,GACxC,IACE,aAAaA,GACd,CAAC,MAAAO,GACA,CAEJ,CAEOF,eAAeG,EAAqBR,GACzC,IACE,aAAaA,GACd,CAAC,MAAOG,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,CAEOE,eAAeI,EACpBC,EACAC,EAAa,EACbC,GAEA,IAAIC,EAAc,EAClB,OACE,IACE,aAAaH,GACd,CAAC,MAAOP,GAEP,GADAU,IACIA,GAAeF,EACjB,MAAMR,EAERS,SAAAA,EAAO,iBAAgBT,aAAiBW,MAAQX,EAAMY,MAAQZ,IAChE,CAEJ"}
@@ -1,3 +1,3 @@
1
- export { ignoreError, ignoreEnoent, ignoreErrorAsync, ignoreEnoentAsync } from "./error.js";
1
+ export { ignoreError, ignoreEnoent, ignoreErrorAsync, ignoreEnoentAsync, withRetry } from "./error.js";
2
2
  export { shuffle } from "./shuffle.js";
3
3
  export { zenkakuAlphanumericalsToHankaku } from "./zenkaku.js";
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{ignoreEnoent,ignoreEnoentAsync,ignoreError,ignoreErrorAsync}from"./error.js";export{shuffle}from"./shuffle.js";export{zenkakuAlphanumericalsToHankaku}from"./zenkaku.js";
1
+ export{ignoreEnoent,ignoreEnoentAsync,ignoreError,ignoreErrorAsync,withRetry}from"./error.js";export{shuffle}from"./shuffle.js";export{zenkakuAlphanumericalsToHankaku}from"./zenkaku.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- function r(r){return r.replace(/[0-9A-Za-z]/g,(r=>{var n;return String.fromCodePoint((null!==(n=r.codePointAt(0))&&void 0!==n?n:0)-65248)}))}export{r as zenkakuAlphanumericalsToHankaku};
1
+ function r(r){return r.replaceAll(/[0-9A-Za-z]/g,(r=>{var n;return String.fromCodePoint((null!==(n=r.codePointAt(0))&&void 0!==n?n:0)-65248)}))}export{r as zenkakuAlphanumericalsToHankaku};
2
2
  //# sourceMappingURL=zenkaku.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"zenkaku.js","sources":["../../src/zenkaku.ts"],"sourcesContent":["export function zenkakuAlphanumericalsToHankaku(str: string): string {\n return str.replace(/[0-9A-Za-z]/g, (s: string) => {\n return String.fromCodePoint((s.codePointAt(0) ?? 0) - 0xfe_e0);\n });\n}\n"],"names":["zenkakuAlphanumericalsToHankaku","str","replace","s","_s$codePointAt","String","fromCodePoint","codePointAt"],"mappings":"AAAO,SAASA,EAAgCC,GAC9C,OAAOA,EAAIC,QAAQ,gBAAiBC,IAAc,IAAAC,EAChD,OAAOC,OAAOC,uBAAcF,EAACD,EAAEI,YAAY,UAAE,IAAAH,EAAAA,EAAI,GAAK,MAAQ,GAElE"}
1
+ {"version":3,"file":"zenkaku.js","sources":["../../src/zenkaku.ts"],"sourcesContent":["export function zenkakuAlphanumericalsToHankaku(str: string): string {\n return str.replaceAll(/[0-9A-Za-z]/g, (s: string) => {\n return String.fromCodePoint((s.codePointAt(0) ?? 0) - 0xfe_e0);\n });\n}\n"],"names":["zenkakuAlphanumericalsToHankaku","str","replaceAll","s","_s$codePointAt","String","fromCodePoint","codePointAt"],"mappings":"AAAO,SAASA,EAAgCC,GAC9C,OAAOA,EAAIC,WAAW,gBAAiBC,IAAc,IAAAC,EACnD,OAAOC,OAAOC,uBAAcF,EAACD,EAAEI,YAAY,UAAE,IAAAH,EAAAA,EAAI,GAAK,MAAQ,GAElE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/shared-lib",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "author": "WillBooster Inc.",
6
6
  "sideEffects": false,
@@ -36,27 +36,27 @@
36
36
  },
37
37
  "prettier": "@willbooster/prettier-config",
38
38
  "devDependencies": {
39
- "@types/eslint": "8.21.1",
39
+ "@types/eslint": "8.37.0",
40
40
  "@types/micromatch": "4.0.2",
41
41
  "@types/prettier": "2.7.2",
42
- "@typescript-eslint/eslint-plugin": "5.53.0",
43
- "@typescript-eslint/parser": "5.53.0",
44
- "@willbooster/eslint-config-ts": "10.0.8",
42
+ "@typescript-eslint/eslint-plugin": "5.59.5",
43
+ "@typescript-eslint/parser": "5.59.5",
44
+ "@willbooster/eslint-config-ts": "10.1.0",
45
45
  "@willbooster/prettier-config": "9.1.1",
46
- "build-ts": "5.7.3",
47
- "eslint": "8.34.0",
48
- "eslint-config-prettier": "8.6.0",
49
- "eslint-import-resolver-typescript": "3.5.3",
46
+ "build-ts": "5.7.7",
47
+ "eslint": "8.40.0",
48
+ "eslint-config-prettier": "8.8.0",
49
+ "eslint-import-resolver-typescript": "3.5.5",
50
50
  "eslint-plugin-import": "2.27.5",
51
- "eslint-plugin-sort-class-members": "1.16.0",
51
+ "eslint-plugin-sort-class-members": "1.18.0",
52
52
  "eslint-plugin-sort-destructure-keys": "1.5.0",
53
- "eslint-plugin-unicorn": "45.0.2",
54
- "lint-staged": "13.1.2",
53
+ "eslint-plugin-unicorn": "47.0.0",
54
+ "lint-staged": "13.2.2",
55
55
  "micromatch": "4.0.5",
56
- "prettier": "2.8.4",
56
+ "prettier": "2.8.8",
57
57
  "sort-package-json": "2.4.1",
58
- "typescript": "4.9.5",
59
- "vitest": "0.29.1"
58
+ "typescript": "5.0.4",
59
+ "vitest": "0.29.8"
60
60
  },
61
61
  "publishConfig": {
62
62
  "access": "public"