@spinajs/util
Advanced tools
Comparing version 2.0.313 to 2.0.314
@@ -26,3 +26,3 @@ export type Constructor<T> = new (...args: any[]) => T; | ||
*/ | ||
export declare function _catch(promise: (...arg: unknown[]) => Promise<unknown>, onError: (err: Error, ...arg: unknown[]) => Promise<void>): (...arg: unknown[]) => Promise<unknown>; | ||
export declare function _catch(promise: (...arg: any[]) => Promise<any>, onError: (err: Error, ...arg: unknown[]) => Promise<void>): (...arg: unknown[]) => Promise<any>; | ||
/** | ||
@@ -36,4 +36,4 @@ * Catch errors from a promise and call the provided error handler if the error matches the filter. | ||
*/ | ||
export declare function _catchFilter(promise: (arg: unknown) => Promise<unknown>, onError: (err: Error) => void, filter: (err: Error) => boolean): (arg?: unknown) => Promise<unknown>; | ||
export declare function _catchValue(promise: (arg: unknown) => Promise<unknown>, onError: (err: Error) => unknown, value: unknown): (arg?: unknown) => Promise<unknown>; | ||
export declare function _catchFilter(promise: (...arg: any[]) => Promise<any>, onError: (err: Error) => void, filter: (err: Error) => boolean): (...arg: unknown[]) => Promise<any>; | ||
export declare function _catchValue(promise: (...arg: any[]) => Promise<any>, onError: (err: Error) => unknown, value: unknown): (...arg: unknown[]) => Promise<any>; | ||
/** | ||
@@ -47,6 +47,6 @@ * Cactches exception of specific type and calls provided error handler. | ||
*/ | ||
export declare function _catchException(promise: (arg: unknown) => Promise<unknown>, onError: (err: Error) => void, exception: Constructor<Error>): (arg?: unknown) => Promise<unknown>; | ||
export declare function _fallback(promise: (arg: unknown) => Promise<unknown>, fallback: (err: Error) => unknown): (arg?: unknown) => Promise<unknown>; | ||
export declare function _catchException(promise: (...arg: any[]) => Promise<any>, onError: (err: Error) => void, exception: Constructor<Error>): (...arg: any[]) => Promise<any>; | ||
export declare function _fallback(promise: (...arg: any[]) => Promise<any>, fallback: (err: Error) => unknown): (...arg: any[]) => Promise<any>; | ||
export declare function _tap(promise: ((arg: any) => Promise<unknown>) | Promise<unknown>): (arg?: unknown) => Promise<unknown>; | ||
export declare function _either(cond: (arg: unknown) => Promise<unknown> | boolean, onFulfilled: (a?: unknown) => Promise<unknown>, onRejected: (arg?: unknown) => Promise<unknown>): (arg?: unknown) => Promise<unknown>; | ||
//# sourceMappingURL=fp.d.ts.map |
@@ -70,3 +70,3 @@ "use strict"; | ||
function _catchFilter(promise, onError, filter) { | ||
return (arg) => Promise.resolve(promise(arg)).catch((err) => { | ||
return (...arg) => Promise.resolve(promise(...arg)).catch((err) => { | ||
if (filter(err)) { | ||
@@ -82,3 +82,3 @@ return onError(err); | ||
function _catchValue(promise, onError, value) { | ||
return (arg) => Promise.resolve(promise(arg)).catch((err) => (err === value ? onError(err) : Promise.reject(err))); | ||
return (...arg) => Promise.resolve(promise(...arg)).catch((err) => (err === value ? onError(err) : Promise.reject(err))); | ||
} | ||
@@ -95,3 +95,3 @@ exports._catchValue = _catchValue; | ||
function _catchException(promise, onError, exception) { | ||
return (arg) => Promise.resolve(promise(arg)).catch((err) => { | ||
return (...arg) => Promise.resolve(promise(...arg)).catch((err) => { | ||
if (typeof err === 'object' && err instanceof exception) { | ||
@@ -107,3 +107,3 @@ return onError(err); | ||
function _fallback(promise, fallback) { | ||
return (arg) => promise(arg).catch(fallback); | ||
return (...arg) => promise(...arg).catch(fallback); | ||
} | ||
@@ -110,0 +110,0 @@ exports._fallback = _fallback; |
@@ -26,3 +26,3 @@ export type Constructor<T> = new (...args: any[]) => T; | ||
*/ | ||
export declare function _catch(promise: (...arg: unknown[]) => Promise<unknown>, onError: (err: Error, ...arg: unknown[]) => Promise<void>): (...arg: unknown[]) => Promise<unknown>; | ||
export declare function _catch(promise: (...arg: any[]) => Promise<any>, onError: (err: Error, ...arg: unknown[]) => Promise<void>): (...arg: unknown[]) => Promise<any>; | ||
/** | ||
@@ -36,4 +36,4 @@ * Catch errors from a promise and call the provided error handler if the error matches the filter. | ||
*/ | ||
export declare function _catchFilter(promise: (arg: unknown) => Promise<unknown>, onError: (err: Error) => void, filter: (err: Error) => boolean): (arg?: unknown) => Promise<unknown>; | ||
export declare function _catchValue(promise: (arg: unknown) => Promise<unknown>, onError: (err: Error) => unknown, value: unknown): (arg?: unknown) => Promise<unknown>; | ||
export declare function _catchFilter(promise: (...arg: any[]) => Promise<any>, onError: (err: Error) => void, filter: (err: Error) => boolean): (...arg: unknown[]) => Promise<any>; | ||
export declare function _catchValue(promise: (...arg: any[]) => Promise<any>, onError: (err: Error) => unknown, value: unknown): (...arg: unknown[]) => Promise<any>; | ||
/** | ||
@@ -47,6 +47,6 @@ * Cactches exception of specific type and calls provided error handler. | ||
*/ | ||
export declare function _catchException(promise: (arg: unknown) => Promise<unknown>, onError: (err: Error) => void, exception: Constructor<Error>): (arg?: unknown) => Promise<unknown>; | ||
export declare function _fallback(promise: (arg: unknown) => Promise<unknown>, fallback: (err: Error) => unknown): (arg?: unknown) => Promise<unknown>; | ||
export declare function _catchException(promise: (...arg: any[]) => Promise<any>, onError: (err: Error) => void, exception: Constructor<Error>): (...arg: any[]) => Promise<any>; | ||
export declare function _fallback(promise: (...arg: any[]) => Promise<any>, fallback: (err: Error) => unknown): (...arg: any[]) => Promise<any>; | ||
export declare function _tap(promise: ((arg: any) => Promise<unknown>) | Promise<unknown>): (arg?: unknown) => Promise<unknown>; | ||
export declare function _either(cond: (arg: unknown) => Promise<unknown> | boolean, onFulfilled: (a?: unknown) => Promise<unknown>, onRejected: (arg?: unknown) => Promise<unknown>): (arg?: unknown) => Promise<unknown>; | ||
//# sourceMappingURL=fp.d.ts.map |
@@ -61,3 +61,3 @@ import { isPromise } from 'util/types'; | ||
export function _catchFilter(promise, onError, filter) { | ||
return (arg) => Promise.resolve(promise(arg)).catch((err) => { | ||
return (...arg) => Promise.resolve(promise(...arg)).catch((err) => { | ||
if (filter(err)) { | ||
@@ -72,3 +72,3 @@ return onError(err); | ||
export function _catchValue(promise, onError, value) { | ||
return (arg) => Promise.resolve(promise(arg)).catch((err) => (err === value ? onError(err) : Promise.reject(err))); | ||
return (...arg) => Promise.resolve(promise(...arg)).catch((err) => (err === value ? onError(err) : Promise.reject(err))); | ||
} | ||
@@ -84,3 +84,3 @@ /** | ||
export function _catchException(promise, onError, exception) { | ||
return (arg) => Promise.resolve(promise(arg)).catch((err) => { | ||
return (...arg) => Promise.resolve(promise(...arg)).catch((err) => { | ||
if (typeof err === 'object' && err instanceof exception) { | ||
@@ -95,3 +95,3 @@ return onError(err); | ||
export function _fallback(promise, fallback) { | ||
return (arg) => promise(arg).catch(fallback); | ||
return (...arg) => promise(...arg).catch(fallback); | ||
} | ||
@@ -98,0 +98,0 @@ export function _tap(promise) { |
{ | ||
"name": "@spinajs/util", | ||
"version": "2.0.313", | ||
"version": "2.0.314", | ||
"description": "utility functions shared across @spinajs framework", | ||
@@ -50,3 +50,3 @@ "main": "lib/cjs/index.js", | ||
"dependencies": { | ||
"@spinajs/exceptions": "^2.0.313", | ||
"@spinajs/exceptions": "^2.0.314", | ||
"glob-to-regexp": "^0.4.1" | ||
@@ -53,0 +53,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
231768
Updated@spinajs/exceptions@^2.0.314