Comparing version 2.0.0-10 to 2.0.0-11
@@ -25,2 +25,3 @@ declare const INTERNAL: unique symbol; | ||
readonly match: (error: unknown) => Data | undefined; | ||
readonly matchExec: <Result>(error: unknown, fn: (data: Data) => Result) => Result | undefined; | ||
} | ||
@@ -70,6 +71,2 @@ declare class Erreur extends Error { | ||
static readonly matchObj: typeof matchObj; | ||
/** | ||
* Either returns the matched erreur data or throw the error | ||
*/ | ||
static readonly matchObjOrThrow: typeof matchObjOrThrow; | ||
static readonly declareWithTransform: typeof declareWithTransform; | ||
@@ -92,4 +89,4 @@ static readonly declareManyFromTypes: typeof declareManyFromTypes; | ||
declare function isOneOfObj(error: unknown, types: ObjDeclarationsBase): error is Erreur; | ||
declare function match<Data>(error: unknown, type: ErreurDeclaration<Data>): Data | undefined; | ||
declare function matchExec<Data, Result>(error: unknown, type: ErreurDeclaration<Data>, exec: (data: Data) => Result): Result | undefined; | ||
declare function match<Data>(error: unknown, type: ErreurDeclaration<Data, any>): Data | undefined; | ||
declare function matchExec<Data, Result>(error: unknown, type: ErreurDeclaration<Data, any>, exec: (data: Data) => Result): Result | undefined; | ||
declare type DataFromTypes<Types extends ObjDeclarationsBase> = { | ||
@@ -102,3 +99,2 @@ [K in keyof Types]: { | ||
declare function matchObj<Types extends ObjDeclarationsBase>(error: unknown, types: Types): DataFromTypes<Types> | undefined; | ||
declare function matchObjOrThrow<Types extends ObjDeclarationsBase>(error: unknown, types: Types): DataFromTypes<Types>; | ||
declare function declareWithTransform<Data, Params extends readonly any[]>(name: string, transform: (...params: Params) => Data): ErreurDeclaration<Data, Params>; | ||
@@ -105,0 +101,0 @@ declare type CreatorsBase = Record<string, (...args: any[]) => any>; |
@@ -51,2 +51,3 @@ var __defProp = Object.defineProperty; | ||
match: (error) => match(error, type), | ||
matchExec: (error, fn) => matchExec(error, type, fn), | ||
withTransform: (subTransform) => declareWithTransform2(subTransform) | ||
@@ -76,3 +77,2 @@ }; | ||
Erreur.matchObj = matchObj; | ||
Erreur.matchObjOrThrow = matchObjOrThrow; | ||
Erreur.declareWithTransform = declareWithTransform; | ||
@@ -161,9 +161,2 @@ Erreur.declareManyFromTypes = declareManyFromTypes; | ||
} | ||
function matchObjOrThrow(error, types) { | ||
const res = matchObj(error, types); | ||
if (res !== void 0) { | ||
return res; | ||
} | ||
throw error; | ||
} | ||
function declareWithTransform(name, transform) { | ||
@@ -170,0 +163,0 @@ return Erreur.declare(name).withTransform(transform); |
{ | ||
"name": "erreur", | ||
"version": "2.0.0-10", | ||
"version": "2.0.0-11", | ||
"description": "Type safe custom errors", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21557
436