@naturalcycles/js-lib 14.84.0 → 14.84.1
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/assert.d.ts +4 -4
- package/dist/error/error.model.d.ts +1 -0
- package/dist/promise/pRetry.d.ts +2 -2
- package/dist/promise/pTimeout.d.ts +3 -2
- package/package.json +1 -1
- package/src/error/assert.ts +4 -4
- package/src/error/error.model.ts +2 -0
- package/src/promise/pRetry.ts +2 -2
- package/src/promise/pTimeout.ts +3 -2
package/dist/error/assert.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorData
|
|
1
|
+
import { ErrorData } from '..';
|
|
2
2
|
import { AppError } from './app.error';
|
|
3
3
|
/**
|
|
4
4
|
* Evaluates the `condition` (casts it to Boolean).
|
|
@@ -16,21 +16,21 @@ import { AppError } from './app.error';
|
|
|
16
16
|
* 3. Sets `userFriendly` flag to true, cause it's always better to have at least SOME clue, rather than fully generic "Oops" error.
|
|
17
17
|
*/
|
|
18
18
|
export declare function _assert(condition: any, // will be evaluated as Boolean
|
|
19
|
-
message?: string, errorData?:
|
|
19
|
+
message?: string, errorData?: ErrorData): asserts condition;
|
|
20
20
|
/**
|
|
21
21
|
* Like _assert(), but prints more helpful error message.
|
|
22
22
|
* API is similar to Node's assert.equals().
|
|
23
23
|
*
|
|
24
24
|
* Does SHALLOW, but strict equality (===), use _assertDeepEquals() for deep equality.
|
|
25
25
|
*/
|
|
26
|
-
export declare function _assertEquals<T>(actual: any, expected: T, message?: string, errorData?:
|
|
26
|
+
export declare function _assertEquals<T>(actual: any, expected: T, message?: string, errorData?: ErrorData): asserts actual is T;
|
|
27
27
|
/**
|
|
28
28
|
* Like _assert(), but prints more helpful error message.
|
|
29
29
|
* API is similar to Node's assert.deepEquals().
|
|
30
30
|
*
|
|
31
31
|
* Does DEEP equality via _deepEquals()
|
|
32
32
|
*/
|
|
33
|
-
export declare function _assertDeepEquals<T>(actual: any, expected: T, message?: string, errorData?:
|
|
33
|
+
export declare function _assertDeepEquals<T>(actual: any, expected: T, message?: string, errorData?: ErrorData): asserts actual is T;
|
|
34
34
|
export declare function _assertIsError<ERR extends Error = Error>(err: any, message?: string): asserts err is ERR;
|
|
35
35
|
export declare function _assertIsString(v: any, message?: string): asserts v is string;
|
|
36
36
|
export declare function _assertIsNumber(v: any, message?: string): asserts v is number;
|
package/dist/promise/pRetry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyFunction,
|
|
1
|
+
import { AnyFunction, CommonLogger, ErrorData } from '..';
|
|
2
2
|
export interface PRetryOptions {
|
|
3
3
|
/**
|
|
4
4
|
* If set - will be included in the error message.
|
|
@@ -79,7 +79,7 @@ export interface PRetryOptions {
|
|
|
79
79
|
/**
|
|
80
80
|
* Will be merged with `err.data` object.
|
|
81
81
|
*/
|
|
82
|
-
errorData?:
|
|
82
|
+
errorData?: ErrorData;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Returns a Function (!), enhanced with retry capabilities.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AppError } from '../error/app.error';
|
|
2
|
-
import {
|
|
2
|
+
import { ErrorData } from '../error/error.model';
|
|
3
|
+
import { AnyFunction } from '../types';
|
|
3
4
|
export declare class TimeoutError extends AppError {
|
|
4
5
|
}
|
|
5
6
|
export interface PTimeoutOptions {
|
|
@@ -28,7 +29,7 @@ export interface PTimeoutOptions {
|
|
|
28
29
|
/**
|
|
29
30
|
* Will be merged with `err.data` object.
|
|
30
31
|
*/
|
|
31
|
-
errorData?:
|
|
32
|
+
errorData?: ErrorData;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* Decorates a Function with a timeout.
|
package/package.json
CHANGED
package/src/error/assert.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorData,
|
|
1
|
+
import { ErrorData, _deepEquals, _stringifyAny } from '..'
|
|
2
2
|
import { AppError } from './app.error'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -19,7 +19,7 @@ import { AppError } from './app.error'
|
|
|
19
19
|
export function _assert(
|
|
20
20
|
condition: any, // will be evaluated as Boolean
|
|
21
21
|
message?: string,
|
|
22
|
-
errorData?:
|
|
22
|
+
errorData?: ErrorData,
|
|
23
23
|
): asserts condition {
|
|
24
24
|
if (!condition) {
|
|
25
25
|
throw new AssertionError(message || 'see stacktrace', {
|
|
@@ -39,7 +39,7 @@ export function _assertEquals<T>(
|
|
|
39
39
|
actual: any,
|
|
40
40
|
expected: T,
|
|
41
41
|
message?: string,
|
|
42
|
-
errorData?:
|
|
42
|
+
errorData?: ErrorData,
|
|
43
43
|
): asserts actual is T {
|
|
44
44
|
if (actual !== expected) {
|
|
45
45
|
const msg = [
|
|
@@ -67,7 +67,7 @@ export function _assertDeepEquals<T>(
|
|
|
67
67
|
actual: any,
|
|
68
68
|
expected: T,
|
|
69
69
|
message?: string,
|
|
70
|
-
errorData?:
|
|
70
|
+
errorData?: ErrorData,
|
|
71
71
|
): asserts actual is T {
|
|
72
72
|
if (!_deepEquals(actual, expected)) {
|
|
73
73
|
const msg = [
|
package/src/error/error.model.ts
CHANGED
package/src/promise/pRetry.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _since, _stringifyAny, AnyFunction,
|
|
1
|
+
import { _since, _stringifyAny, AnyFunction, AppError, CommonLogger, ErrorData } from '..'
|
|
2
2
|
import { TimeoutError } from './pTimeout'
|
|
3
3
|
|
|
4
4
|
export interface PRetryOptions {
|
|
@@ -95,7 +95,7 @@ export interface PRetryOptions {
|
|
|
95
95
|
/**
|
|
96
96
|
* Will be merged with `err.data` object.
|
|
97
97
|
*/
|
|
98
|
-
errorData?:
|
|
98
|
+
errorData?: ErrorData
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
package/src/promise/pTimeout.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AppError } from '../error/app.error'
|
|
2
|
-
import {
|
|
2
|
+
import { ErrorData } from '../error/error.model'
|
|
3
|
+
import { AnyFunction } from '../types'
|
|
3
4
|
|
|
4
5
|
export class TimeoutError extends AppError {}
|
|
5
6
|
|
|
@@ -33,7 +34,7 @@ export interface PTimeoutOptions {
|
|
|
33
34
|
/**
|
|
34
35
|
* Will be merged with `err.data` object.
|
|
35
36
|
*/
|
|
36
|
-
errorData?:
|
|
37
|
+
errorData?: ErrorData
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|