@willbooster/shared-lib 6.0.1 → 6.0.2
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/error.cjs.map +1 -1
- package/dist/error.js.map +1 -1
- package/package.json +3 -3
package/dist/error.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.cjs","sources":["../src/error.ts"],"sourcesContent":["import { sleep } from './sleep.js';\n\n/**\n * Convert an object to an error.\n * @param obj The object to convert.\n */\nexport function errorify(obj: unknown): Error {\n if (obj instanceof Error) return obj;\n if (typeof obj === 'string') return new Error(obj);\n try {\n return new Error(JSON.stringify(obj));\n } catch {\n return new Error(String(obj));\n }\n}\n\nexport 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 interface RetryOptions {\n beforeRetry?: (error: unknown) => Promise<void>;\n handleError?: (error: unknown) => Promise<void>;\n retryCount?: number;\n retryLogger?: (message: string) => void;\n shouldRetry?: (error: unknown) => boolean;\n sleepMilliseconds?: number;\n updateSleepMilliseconds?: (sleepMilliseconds: number) => number;\n}\n\n/**\n * Retry the given function.\n * @param func The function to retry.\n * @param beforeRetry The function to call immediately before retrying.\n * @param handleError The function to call when an error occurs.\n * @param retryCount The maximum number of retries.\n * @param retryLogger The function to log retrying.\n * @param sleepMilliseconds The number of milliseconds to sleep before retrying.\n * @param updateSleepMilliseconds The function to update sleep milliseconds after each retry.\n */\nexport async function withRetry<T>(\n func: (failedCount: number) => T | Promise<T>,\n {\n beforeRetry,\n handleError,\n retryCount = 3,\n retryLogger,\n shouldRetry,\n sleepMilliseconds = 0,\n updateSleepMilliseconds,\n }: RetryOptions = {}\n): Promise<T> {\n let failedCount = 0;\n for (;;) {\n try {\n return await func(failedCount);\n } catch (error) {\n await handleError?.(error);\n failedCount++;\n if (failedCount >= retryCount) {\n throw error;\n }\n if (shouldRetry && !shouldRetry(error)) {\n throw error;\n }\n if (sleepMilliseconds > 0) {\n await sleep(sleepMilliseconds);\n }\n if (updateSleepMilliseconds) {\n sleepMilliseconds = updateSleepMilliseconds(sleepMilliseconds);\n }\n retryLogger?.(`Retry due to: ${error}\n${error instanceof Error ? '---\\n' + error.stack : ''}`);\n await beforeRetry?.(error);\n }\n }\n}\n"],"names":["obj","Error","JSON","stringify","_unused","String","fn","error","code","async","_unused2","_unused3","func","beforeRetry","handleError","retryCount","retryLogger","shouldRetry","sleepMilliseconds","updateSleepMilliseconds","failedCount","sleep","stack"],"mappings":"2DAMO,SAAkBA,GACvB,GAAIA,aAAeC,MAAO,OAAOD,EACjC,GAAmB,iBAARA,EAAkB,OAAO,IAAIC,MAAMD,GAC9C,IACE,OAAO,IAAIC,MAAMC,KAAKC,UAAUH,
|
|
1
|
+
{"version":3,"file":"error.cjs","sources":["../src/error.ts"],"sourcesContent":["import { sleep } from './sleep.js';\n\n/**\n * Convert an object to an error.\n * @param obj The object to convert.\n */\nexport function errorify(obj: unknown): Error {\n if (obj instanceof Error) return obj;\n if (typeof obj === 'string') return new Error(obj);\n try {\n return new Error(JSON.stringify(obj));\n } catch {\n return new Error(String(obj));\n }\n}\n\nexport 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 interface RetryOptions {\n beforeRetry?: (error: unknown) => Promise<void>;\n handleError?: (error: unknown) => Promise<void>;\n retryCount?: number;\n retryLogger?: (message: string) => void;\n shouldRetry?: (error: unknown) => boolean;\n sleepMilliseconds?: number;\n updateSleepMilliseconds?: (sleepMilliseconds: number) => number;\n}\n\n/**\n * Retry the given function.\n * @param func The function to retry.\n * @param beforeRetry The function to call immediately before retrying.\n * @param handleError The function to call when an error occurs.\n * @param retryCount The maximum number of retries.\n * @param retryLogger The function to log retrying.\n * @param sleepMilliseconds The number of milliseconds to sleep before retrying.\n * @param updateSleepMilliseconds The function to update sleep milliseconds after each retry.\n */\nexport async function withRetry<T>(\n func: (failedCount: number) => T | Promise<T>,\n {\n beforeRetry,\n handleError,\n retryCount = 3,\n retryLogger,\n shouldRetry,\n sleepMilliseconds = 0,\n updateSleepMilliseconds,\n }: RetryOptions = {}\n): Promise<T> {\n let failedCount = 0;\n for (;;) {\n try {\n return await func(failedCount);\n } catch (error) {\n await handleError?.(error);\n failedCount++;\n if (failedCount >= retryCount) {\n throw error;\n }\n if (shouldRetry && !shouldRetry(error)) {\n throw error;\n }\n if (sleepMilliseconds > 0) {\n await sleep(sleepMilliseconds);\n }\n if (updateSleepMilliseconds) {\n sleepMilliseconds = updateSleepMilliseconds(sleepMilliseconds);\n }\n retryLogger?.(`Retry due to: ${error}\n${error instanceof Error ? '---\\n' + error.stack : ''}`);\n await beforeRetry?.(error);\n }\n }\n}\n"],"names":["obj","Error","JSON","stringify","_unused","String","fn","error","code","async","_unused2","_unused3","func","beforeRetry","handleError","retryCount","retryLogger","shouldRetry","sleepMilliseconds","updateSleepMilliseconds","failedCount","sleep","stack"],"mappings":"2DAMO,SAAkBA,GACvB,GAAIA,aAAeC,MAAO,OAAOD,EACjC,GAAmB,iBAARA,EAAkB,OAAO,IAAIC,MAAMD,GAC9C,IACE,OAAO,IAAIC,MAAMC,KAAKC,UAAUH,GAClC,CAAE,MAAAI,GACA,OAAO,IAAIH,MAAMI,OAAOL,GAC1B,CACF,uBAUO,SAAyBM,GAC9B,IACE,OAAOA,GACT,CAAE,MAAOC,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,4BAUOE,eAAoCH,GACzC,IACE,aAAaA,GACf,CAAE,MAAOC,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,sBApCO,SAAwBD,GAC7B,IACE,OAAOA,GACT,CAAE,MAAAI,GACA,CAEJ,2BAaOD,eAAmCH,GACxC,IACE,aAAaA,GACf,CAAE,MAAAK,GACA,CAEJ,oBAiCOF,eACLG,GACAC,YACEA,EAAWC,YACXA,EAAWC,WACXA,EAAa,EAACC,YACdA,EAAWC,YACXA,EAAWC,kBACXA,EAAoB,EAACC,wBACrBA,GACgB,IAElB,IAAIC,EAAc,EAClB,OACE,IACE,aAAaR,EAAKQ,EACpB,CAAE,MAAOb,GAGP,SAFiB,MAAXO,OAAW,EAAXA,EAAcP,IACpBa,IACIA,GAAeL,EACjB,MAAMR,EAER,GAAIU,IAAgBA,EAAYV,GAC9B,MAAMA,EAEJW,EAAoB,SAChBG,EAAAA,MAAMH,GAEVC,IACFD,EAAoBC,EAAwBD,IAEnC,MAAXF,GAAAA,EAAc,iBAAiBT,MACnCA,aAAiBN,MAAQ,QAAUM,EAAMe,MAAQ,YAC5B,MAAXT,OAAW,EAAXA,EAAcN,GACtB,CAEJ"}
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sources":["../src/error.ts"],"sourcesContent":["import { sleep } from './sleep.js';\n\n/**\n * Convert an object to an error.\n * @param obj The object to convert.\n */\nexport function errorify(obj: unknown): Error {\n if (obj instanceof Error) return obj;\n if (typeof obj === 'string') return new Error(obj);\n try {\n return new Error(JSON.stringify(obj));\n } catch {\n return new Error(String(obj));\n }\n}\n\nexport 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 interface RetryOptions {\n beforeRetry?: (error: unknown) => Promise<void>;\n handleError?: (error: unknown) => Promise<void>;\n retryCount?: number;\n retryLogger?: (message: string) => void;\n shouldRetry?: (error: unknown) => boolean;\n sleepMilliseconds?: number;\n updateSleepMilliseconds?: (sleepMilliseconds: number) => number;\n}\n\n/**\n * Retry the given function.\n * @param func The function to retry.\n * @param beforeRetry The function to call immediately before retrying.\n * @param handleError The function to call when an error occurs.\n * @param retryCount The maximum number of retries.\n * @param retryLogger The function to log retrying.\n * @param sleepMilliseconds The number of milliseconds to sleep before retrying.\n * @param updateSleepMilliseconds The function to update sleep milliseconds after each retry.\n */\nexport async function withRetry<T>(\n func: (failedCount: number) => T | Promise<T>,\n {\n beforeRetry,\n handleError,\n retryCount = 3,\n retryLogger,\n shouldRetry,\n sleepMilliseconds = 0,\n updateSleepMilliseconds,\n }: RetryOptions = {}\n): Promise<T> {\n let failedCount = 0;\n for (;;) {\n try {\n return await func(failedCount);\n } catch (error) {\n await handleError?.(error);\n failedCount++;\n if (failedCount >= retryCount) {\n throw error;\n }\n if (shouldRetry && !shouldRetry(error)) {\n throw error;\n }\n if (sleepMilliseconds > 0) {\n await sleep(sleepMilliseconds);\n }\n if (updateSleepMilliseconds) {\n sleepMilliseconds = updateSleepMilliseconds(sleepMilliseconds);\n }\n retryLogger?.(`Retry due to: ${error}\n${error instanceof Error ? '---\\n' + error.stack : ''}`);\n await beforeRetry?.(error);\n }\n }\n}\n"],"names":["errorify","obj","Error","JSON","stringify","_unused","String","ignoreError","fn","_unused2","ignoreEnoent","error","code","async","ignoreErrorAsync","_unused3","ignoreEnoentAsync","withRetry","func","beforeRetry","handleError","retryCount","retryLogger","shouldRetry","sleepMilliseconds","updateSleepMilliseconds","failedCount","sleep","stack"],"mappings":"mCAMO,SAASA,EAASC,GACvB,GAAIA,aAAeC,MAAO,OAAOD,EACjC,GAAmB,iBAARA,EAAkB,OAAO,IAAIC,MAAMD,GAC9C,IACE,OAAO,IAAIC,MAAMC,KAAKC,UAAUH,
|
|
1
|
+
{"version":3,"file":"error.js","sources":["../src/error.ts"],"sourcesContent":["import { sleep } from './sleep.js';\n\n/**\n * Convert an object to an error.\n * @param obj The object to convert.\n */\nexport function errorify(obj: unknown): Error {\n if (obj instanceof Error) return obj;\n if (typeof obj === 'string') return new Error(obj);\n try {\n return new Error(JSON.stringify(obj));\n } catch {\n return new Error(String(obj));\n }\n}\n\nexport 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 interface RetryOptions {\n beforeRetry?: (error: unknown) => Promise<void>;\n handleError?: (error: unknown) => Promise<void>;\n retryCount?: number;\n retryLogger?: (message: string) => void;\n shouldRetry?: (error: unknown) => boolean;\n sleepMilliseconds?: number;\n updateSleepMilliseconds?: (sleepMilliseconds: number) => number;\n}\n\n/**\n * Retry the given function.\n * @param func The function to retry.\n * @param beforeRetry The function to call immediately before retrying.\n * @param handleError The function to call when an error occurs.\n * @param retryCount The maximum number of retries.\n * @param retryLogger The function to log retrying.\n * @param sleepMilliseconds The number of milliseconds to sleep before retrying.\n * @param updateSleepMilliseconds The function to update sleep milliseconds after each retry.\n */\nexport async function withRetry<T>(\n func: (failedCount: number) => T | Promise<T>,\n {\n beforeRetry,\n handleError,\n retryCount = 3,\n retryLogger,\n shouldRetry,\n sleepMilliseconds = 0,\n updateSleepMilliseconds,\n }: RetryOptions = {}\n): Promise<T> {\n let failedCount = 0;\n for (;;) {\n try {\n return await func(failedCount);\n } catch (error) {\n await handleError?.(error);\n failedCount++;\n if (failedCount >= retryCount) {\n throw error;\n }\n if (shouldRetry && !shouldRetry(error)) {\n throw error;\n }\n if (sleepMilliseconds > 0) {\n await sleep(sleepMilliseconds);\n }\n if (updateSleepMilliseconds) {\n sleepMilliseconds = updateSleepMilliseconds(sleepMilliseconds);\n }\n retryLogger?.(`Retry due to: ${error}\n${error instanceof Error ? '---\\n' + error.stack : ''}`);\n await beforeRetry?.(error);\n }\n }\n}\n"],"names":["errorify","obj","Error","JSON","stringify","_unused","String","ignoreError","fn","_unused2","ignoreEnoent","error","code","async","ignoreErrorAsync","_unused3","ignoreEnoentAsync","withRetry","func","beforeRetry","handleError","retryCount","retryLogger","shouldRetry","sleepMilliseconds","updateSleepMilliseconds","failedCount","sleep","stack"],"mappings":"mCAMO,SAASA,EAASC,GACvB,GAAIA,aAAeC,MAAO,OAAOD,EACjC,GAAmB,iBAARA,EAAkB,OAAO,IAAIC,MAAMD,GAC9C,IACE,OAAO,IAAIC,MAAMC,KAAKC,UAAUH,GAClC,CAAE,MAAAI,GACA,OAAO,IAAIH,MAAMI,OAAOL,GAC1B,CACF,CAEO,SAASM,EAAeC,GAC7B,IACE,OAAOA,GACT,CAAE,MAAAC,GACA,CAEJ,CAEO,SAASC,EAAgBF,GAC9B,IACE,OAAOA,GACT,CAAE,MAAOG,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,CAEOE,eAAeC,EAAoBN,GACxC,IACE,aAAaA,GACf,CAAE,MAAAO,GACA,CAEJ,CAEOF,eAAeG,EAAqBR,GACzC,IACE,aAAaA,GACf,CAAE,MAAOG,GACP,GAAqB,iBAAVA,GAAsBA,GAAS,SAAUA,GAAwB,WAAfA,EAAMC,KACjE,OAEF,MAAMD,CACR,CACF,CAsBOE,eAAeI,EACpBC,GACAC,YACEA,EAAWC,YACXA,EAAWC,WACXA,EAAa,EAACC,YACdA,EAAWC,YACXA,EAAWC,kBACXA,EAAoB,EAACC,wBACrBA,GACgB,IAElB,IAAIC,EAAc,EAClB,OACE,IACE,aAAaR,EAAKQ,EACpB,CAAE,MAAOf,GAGP,SAFiB,MAAXS,OAAW,EAAXA,EAAcT,IACpBe,IACIA,GAAeL,EACjB,MAAMV,EAER,GAAIY,IAAgBA,EAAYZ,GAC9B,MAAMA,EAEJa,EAAoB,SAChBG,EAAMH,GAEVC,IACFD,EAAoBC,EAAwBD,IAEnC,MAAXF,GAAAA,EAAc,iBAAiBX,MACnCA,aAAiBT,MAAQ,QAAUS,EAAMiB,MAAQ,YAC5B,MAAXT,OAAW,EAAXA,EAAcR,GACtB,CAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/shared-lib",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "WillBooster Inc.",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/micromatch": "4.0.9",
|
|
43
43
|
"@willbooster/eslint-config-ts": "11.4.0",
|
|
44
44
|
"@willbooster/prettier-config": "10.2.0",
|
|
45
|
-
"build-ts": "15.0.
|
|
45
|
+
"build-ts": "15.0.12",
|
|
46
46
|
"eslint": "9.30.1",
|
|
47
47
|
"eslint-config-flat-gitignore": "2.1.0",
|
|
48
48
|
"eslint-config-prettier": "10.1.5",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"prettier-plugin-java": "2.7.1",
|
|
60
60
|
"sort-package-json": "3.4.0",
|
|
61
61
|
"typescript": "5.8.3",
|
|
62
|
-
"typescript-eslint": "8.
|
|
62
|
+
"typescript-eslint": "8.36.0",
|
|
63
63
|
"vitest": "3.2.4"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|