@xylabs/error
Advanced tools
@@ -1,3 +0,2 @@ | ||
| export * from './assert.ts'; | ||
| export * from './handleError.ts'; | ||
| export * from '@ariestools/sdk/error'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"} |
@@ -1,32 +0,3 @@ | ||
| // src/assert.ts | ||
| import { isString, isUndefined } from "@xylabs/typeof"; | ||
| var assertError = (value, assert, defaultMessage) => { | ||
| if (!isUndefined(assert)) { | ||
| const assertString = typeof assert === "string" ? assert : typeof assert === "boolean" ? defaultMessage : assert(value, defaultMessage); | ||
| if (isString(assertString) || assertString) { | ||
| throw new Error(assertString === true ? defaultMessage : assertString); | ||
| } | ||
| } | ||
| return void 0; | ||
| }; | ||
| // src/handleError.ts | ||
| import { isError } from "@xylabs/typeof"; | ||
| var handleError = (error, handler) => { | ||
| if (isError(error)) { | ||
| return handler(error); | ||
| } | ||
| throw error; | ||
| }; | ||
| var handleErrorAsync = async (error, handler) => { | ||
| if (isError(error)) { | ||
| return await handler(error); | ||
| } | ||
| throw error; | ||
| }; | ||
| export { | ||
| assertError, | ||
| handleError, | ||
| handleErrorAsync | ||
| }; | ||
| // src/index.ts | ||
| export * from "@ariestools/sdk/error"; | ||
| //# sourceMappingURL=index.mjs.map |
| { | ||
| "version": 3, | ||
| "sources": ["../../src/assert.ts", "../../src/handleError.ts"], | ||
| "sourcesContent": ["import { isString, isUndefined } from '@xylabs/typeof'\n\ntype AssertCallback = (value: unknown, message: string) => string | boolean\n\n/** Configuration for assertion behavior: a static message string, a boolean toggle, or a callback. */\nexport type AssertConfig = string | AssertCallback | boolean\n\n/**\n * Throws an Error based on the assert configuration when a value fails validation.\n * @param value - The value being validated\n * @param assert - Assertion config controlling the error message\n * @param defaultMessage - Fallback message if no custom message is provided\n */\nexport const assertError = (value: unknown, assert: AssertConfig | undefined, defaultMessage: string) => {\n if (!isUndefined(assert)) {\n const assertString\n = typeof assert === 'string'\n ? assert\n : typeof assert === 'boolean'\n ? defaultMessage\n : assert(value, defaultMessage)\n if (isString(assertString) || assertString) {\n throw new Error(assertString === true ? defaultMessage : assertString)\n }\n }\n // eslint-disable-next-line unicorn/no-useless-undefined\n return undefined\n}\n", "import { isError } from '@xylabs/typeof'\n\n/**\n * Invokes the handler if the value is an Error, otherwise re-throws it.\n * @param error - The caught value to inspect\n * @param handler - Callback invoked with the Error if it is one\n * @returns The handler's return value\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n }\n throw error\n}\n\n/**\n * Async version of handleError. Invokes the async handler if the value is an Error, otherwise re-throws it.\n * @param error - The caught value to inspect\n * @param handler - Async callback invoked with the Error if it is one\n * @returns The handler's resolved return value\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n }\n throw error\n}\n"], | ||
| "mappings": ";AAAA,SAAS,UAAU,mBAAmB;AAa/B,IAAM,cAAc,CAAC,OAAgB,QAAkC,mBAA2B;AACvG,MAAI,CAAC,YAAY,MAAM,GAAG;AACxB,UAAM,eACF,OAAO,WAAW,WAChB,SACA,OAAO,WAAW,YAChB,iBACA,OAAO,OAAO,cAAc;AACpC,QAAI,SAAS,YAAY,KAAK,cAAc;AAC1C,YAAM,IAAI,MAAM,iBAAiB,OAAO,iBAAiB,YAAY;AAAA,IACvE;AAAA,EACF;AAEA,SAAO;AACT;;;AC3BA,SAAS,eAAe;AASjB,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB;AACA,QAAM;AACR;AASO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B;AACA,QAAM;AACR;", | ||
| "sources": ["../../src/index.ts"], | ||
| "sourcesContent": ["export * from '@ariestools/sdk/error'\n"], | ||
| "mappings": ";AAAA,cAAc;", | ||
| "names": [] | ||
| } |
@@ -1,2 +0,2 @@ | ||
| export type { AssertConfig } from './assert.ts'; | ||
| export type * from '@ariestools/sdk/error/model'; | ||
| //# sourceMappingURL=model.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA"} | ||
| {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA,mBAAmB,6BAA6B,CAAA"} |
+23
-15
| { | ||
| "name": "@xylabs/error", | ||
| "version": "7.0.2", | ||
| "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries", | ||
| "version": "7.0.3", | ||
| "description": "DEPRECATED — use @ariestools/sdk/error. Backward-compatibility re-export shim.", | ||
| "keywords": [ | ||
| "error", | ||
| "xylabs", | ||
@@ -12,10 +11,10 @@ "utility", | ||
| ], | ||
| "homepage": "https://xyo.network", | ||
| "homepage": "https://xylabs.com", | ||
| "bugs": { | ||
| "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues", | ||
| "email": "support@xyo.network" | ||
| "url": "git+https://github.com/xylabs/sdk-js/issues", | ||
| "email": "support@xylabs.com" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js.git" | ||
| "url": "git+https://github.com/xylabs/sdk-js.git" | ||
| }, | ||
@@ -35,7 +34,7 @@ "license": "LGPL-3.0-only", | ||
| }, | ||
| "./package.json": "./package.json", | ||
| "./model": { | ||
| "types": "./dist/neutral/model.d.ts", | ||
| "default": "./dist/neutral/model.mjs" | ||
| }, | ||
| "./package.json": "./package.json" | ||
| } | ||
| }, | ||
@@ -50,7 +49,10 @@ "files": [ | ||
| "dependencies": { | ||
| "@xylabs/typeof": "~7.0.2" | ||
| "@ariestools/sdk": "~7.0.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@xylabs/toolchain": "^8.5.3", | ||
| "@xylabs/tsconfig": "^8.5.3", | ||
| "@opentelemetry/api": "^1.9.1", | ||
| "@opentelemetry/sdk-trace-base": "^2.8.0", | ||
| "@xylabs/toolchain": "^8.5.5", | ||
| "@xylabs/tsconfig": "^8.5.5", | ||
| "async-mutex": "^0.5.0", | ||
| "browserslist": "4.28.4", | ||
@@ -60,5 +62,10 @@ "eslint": "^10.6.0", | ||
| "typescript": "^6.0.3", | ||
| "vite": "^8.1.0", | ||
| "vitest": "^4.1.9" | ||
| "zod": "^4.4.3" | ||
| }, | ||
| "peerDependencies": { | ||
| "@opentelemetry/api": "^1.9", | ||
| "@opentelemetry/sdk-trace-base": "^2.7", | ||
| "async-mutex": "^0.5", | ||
| "zod": "^4.4" | ||
| }, | ||
| "engines": { | ||
@@ -69,3 +76,4 @@ "node": ">=18" | ||
| "access": "public" | ||
| } | ||
| }, | ||
| "deprecated": "Use @ariestools/sdk/error instead. @xylabs/error is a compatibility shim only and will not receive further updates." | ||
| } |
+6
-4
@@ -0,1 +1,3 @@ | ||
| > **Deprecated.** Use [`@ariestools/sdk`](../../ariestools-sdk/README.md) instead. This package is a backward-compatibility re-export shim. | ||
| [![logo][]](https://xylabs.com) | ||
@@ -15,3 +17,3 @@ | ||
| ```sh | ||
| npm install {{name}} | ||
| npm install @xylabs/error | ||
| ``` | ||
@@ -22,3 +24,3 @@ | ||
| ```sh | ||
| yarn add {{name}} | ||
| yarn add @xylabs/error | ||
| ``` | ||
@@ -29,3 +31,3 @@ | ||
| ```sh | ||
| pnpm add {{name}} | ||
| pnpm add @xylabs/error | ||
| ``` | ||
@@ -36,3 +38,3 @@ | ||
| ```sh | ||
| bun add {{name}} | ||
| bun add @xylabs/error | ||
| ``` | ||
@@ -39,0 +41,0 @@ |
| type AssertCallback = (value: unknown, message: string) => string | boolean; | ||
| /** Configuration for assertion behavior: a static message string, a boolean toggle, or a callback. */ | ||
| export type AssertConfig = string | AssertCallback | boolean; | ||
| /** | ||
| * Throws an Error based on the assert configuration when a value fails validation. | ||
| * @param value - The value being validated | ||
| * @param assert - Assertion config controlling the error message | ||
| * @param defaultMessage - Fallback message if no custom message is provided | ||
| */ | ||
| export declare const assertError: (value: unknown, assert: AssertConfig | undefined, defaultMessage: string) => undefined; | ||
| export {}; | ||
| //# sourceMappingURL=assert.d.ts.map |
| {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/assert.ts"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAA;AAE3E,sGAAsG;AACtG,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,CAAA;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,EAAE,QAAQ,YAAY,GAAG,SAAS,EAAE,gBAAgB,MAAM,cAcnG,CAAA"} |
| /** | ||
| * Invokes the handler if the value is an Error, otherwise re-throws it. | ||
| * @param error - The caught value to inspect | ||
| * @param handler - Callback invoked with the Error if it is one | ||
| * @returns The handler's return value | ||
| */ | ||
| export declare const handleError: <T>(error: any, handler: (error: Error) => T) => T; | ||
| /** | ||
| * Async version of handleError. Invokes the async handler if the value is an Error, otherwise re-throws it. | ||
| * @param error - The caught value to inspect | ||
| * @param handler - Async callback invoked with the Error if it is one | ||
| * @returns The handler's resolved return value | ||
| */ | ||
| export declare const handleErrorAsync: <T>(error: any, handler: (error: Error) => Promise<T>) => Promise<T>; | ||
| //# sourceMappingURL=handleError.d.ts.map |
| {"version":3,"file":"handleError.d.ts","sourceRoot":"","sources":["../../src/handleError.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,MAKtE,CAAA;AAED;;;;;GAKG;AAEH,eAAO,MAAM,gBAAgB,GAAU,CAAC,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,eAK1F,CAAA"} |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
191
1.06%13215
-28.14%5
400%10
25%11
-26.67%6
-90%1
Infinity%1
Infinity%+ Added
+ Added
- Removed
- Removed
- Removed