@naturalcycles/js-lib 14.105.1 → 14.107.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/error.util.d.ts +13 -0
- package/dist/error/error.util.js +20 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +4 -21
- package/dist/types.d.ts +12 -0
- package/dist/types.js +14 -1
- package/dist-esm/error/error.util.js +15 -0
- package/dist-esm/index.js +4 -4
- package/dist-esm/types.js +12 -0
- package/package.json +1 -1
- package/src/error/error.util.ts +19 -0
- package/src/index.ts +4 -34
- package/src/types.ts +13 -0
|
@@ -24,3 +24,16 @@ export declare function _isHttpErrorObject(o: any): o is ErrorObject<HttpErrorDa
|
|
|
24
24
|
* Note: any instance of AppError is also automatically an ErrorObject
|
|
25
25
|
*/
|
|
26
26
|
export declare function _isErrorObject(o: any): o is ErrorObject;
|
|
27
|
+
/**
|
|
28
|
+
* Convenience function to safely add properties to Error's `data` object
|
|
29
|
+
* (even if it wasn't previously existing)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
*
|
|
33
|
+
* try {} catch (err) {
|
|
34
|
+
* _errorDataAppend(err, {
|
|
35
|
+
* httpStatusCode: 401,
|
|
36
|
+
* })
|
|
37
|
+
* }
|
|
38
|
+
*/
|
|
39
|
+
export declare function _errorDataAppend(err: any, data: ErrorData): void;
|
package/dist/error/error.util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._isErrorObject = exports._isHttpErrorObject = exports._isHttpErrorResponse = exports._errorObjectToError = exports._errorObjectToAppError = exports._errorToErrorObject = exports._anyToErrorObject = exports._anyToError = void 0;
|
|
3
|
+
exports._errorDataAppend = exports._isErrorObject = exports._isHttpErrorObject = exports._isHttpErrorResponse = exports._errorObjectToError = exports._errorObjectToAppError = exports._errorToErrorObject = exports._anyToErrorObject = exports._anyToError = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
/**
|
|
6
6
|
* Useful to ensure that error in `catch (err) { ... }`
|
|
@@ -108,3 +108,22 @@ function _isErrorObject(o) {
|
|
|
108
108
|
return (!!o && typeof o.name === 'string' && typeof o.message === 'string' && typeof o.data === 'object');
|
|
109
109
|
}
|
|
110
110
|
exports._isErrorObject = _isErrorObject;
|
|
111
|
+
/**
|
|
112
|
+
* Convenience function to safely add properties to Error's `data` object
|
|
113
|
+
* (even if it wasn't previously existing)
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
*
|
|
117
|
+
* try {} catch (err) {
|
|
118
|
+
* _errorDataAppend(err, {
|
|
119
|
+
* httpStatusCode: 401,
|
|
120
|
+
* })
|
|
121
|
+
* }
|
|
122
|
+
*/
|
|
123
|
+
function _errorDataAppend(err, data) {
|
|
124
|
+
err.data = {
|
|
125
|
+
...err.data,
|
|
126
|
+
...data,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
exports._errorDataAppend = _errorDataAppend;
|
package/dist/index.d.ts
CHANGED
|
@@ -53,12 +53,15 @@ import { JsonStringifyFunction, StringifyAnyOptions, _stringifyAny } from './str
|
|
|
53
53
|
export * from './time/time.util';
|
|
54
54
|
export * from './is.util';
|
|
55
55
|
import { Class, ConditionalExcept, ConditionalPick, Merge, Promisable, ReadonlyDeep, Simplify } from './typeFest';
|
|
56
|
-
import { AsyncMapper, AsyncPredicate, BaseDBEntity, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, Saved, Unsaved, UnsavedId, BatchResult, InstanceId, IsoDate, IsoDateString, IsoDateTimeString, KeyValueTuple, Mapper, ObjectMapper, ObjectPredicate, Predicate, PromiseMap, AnyObject, AnyEnum, NumberEnum, StringEnum, AnyFunction, Reviver, SavedDBEntity, StringMap, UnixTimestampNumber, UnixTimestampMillisNumber, UnixTimestamp, Integer, ValueOf, ValuesOf, AbortableMapper, AbortableAsyncPredicate, AbortableAsyncMapper, AbortablePredicate, NullishValue, FalsyValue
|
|
56
|
+
import { AsyncMapper, AsyncPredicate, BaseDBEntity, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, Saved, Unsaved, UnsavedId, BatchResult, InstanceId, IsoDate, IsoDateString, IsoDateTimeString, KeyValueTuple, Mapper, ObjectMapper, ObjectPredicate, Predicate, PromiseMap, AnyObject, AnyEnum, NumberEnum, StringEnum, AnyFunction, Reviver, SavedDBEntity, StringMap, UnixTimestampNumber, UnixTimestampMillisNumber, UnixTimestamp, Integer, ValueOf, ValuesOf, AbortableMapper, AbortableAsyncPredicate, AbortableAsyncMapper, AbortablePredicate, NullishValue, FalsyValue } from './types';
|
|
57
|
+
export * from './types';
|
|
57
58
|
export * from './unit/size.util';
|
|
58
59
|
import { is } from './vendor/is';
|
|
59
|
-
import { CommonLogLevel, CommonLogFunction, CommonLogger,
|
|
60
|
+
import { CommonLogLevel, CommonLogFunction, CommonLogger, CommonLogWithLevelFunction } from './log/commonLogger';
|
|
61
|
+
export * from './log/commonLogger';
|
|
60
62
|
export * from './string/safeJsonStringify';
|
|
61
|
-
import {
|
|
63
|
+
import { PQueueCfg } from './promise/pQueue';
|
|
64
|
+
export * from './promise/pQueue';
|
|
62
65
|
export * from './seq/seq';
|
|
63
66
|
export * from './math/stack.util';
|
|
64
67
|
export * from './string/leven';
|
|
@@ -71,4 +74,4 @@ import { LocalTimeConfig, LocalTimeFormatter, LocalTimeUnit, LocalTimeComponents
|
|
|
71
74
|
import { DateIntervalConfig, DateIntervalString } from './datetime/dateInterval';
|
|
72
75
|
import { TimeIntervalConfig, TimeIntervalString } from './datetime/timeInterval';
|
|
73
76
|
export type { DateIntervalConfig, DateIntervalString, TimeIntervalConfig, TimeIntervalString, LocalDateConfig, LocalDateFormatter, LocalDateUnit, LocalDateUnitStrict, Inclusiveness, LocalTimeConfig, LocalTimeFormatter, LocalTimeUnit, ISODayOfWeek, LocalTimeComponents, AbortableMapper, AbortablePredicate, AbortableAsyncPredicate, AbortableAsyncMapper, PQueueCfg, MemoCache, AsyncMemoCache, PromiseDecoratorCfg, PromiseDecoratorResp, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, Admin401ErrorData, Admin403ErrorData, StringMap, PromiseMap, AnyObject, AnyEnum, NumberEnum, StringEnum, AnyFunction, ValuesOf, ValueOf, KeyValueTuple, ObjectMapper, ObjectPredicate, InstanceId, IsoDate, IsoDateString, IsoDateTimeString, Reviver, FalsyValue, NullishValue, PMapOptions, Mapper, AsyncMapper, Predicate, AsyncPredicate, BatchResult, DeferredPromise, PRetryOptions, PTimeoutOptions, TryCatchOptions, StringifyAnyOptions, JsonStringifyFunction, Merge, ReadonlyDeep, Promisable, Simplify, ConditionalPick, ConditionalExcept, Class, UnixTimestampNumber, UnixTimestampMillisNumber, UnixTimestamp, Integer, BaseDBEntity, SavedDBEntity, Saved, Unsaved, UnsavedId, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, JsonSchema, JsonSchemaAny, JsonSchemaOneOf, JsonSchemaAllOf, JsonSchemaAnyOf, JsonSchemaNot, JsonSchemaRef, JsonSchemaConst, JsonSchemaEnum, JsonSchemaString, JsonSchemaNumber, JsonSchemaBoolean, JsonSchemaNull, JsonSchemaRootObject, JsonSchemaObject, JsonSchemaArray, JsonSchemaTuple, JsonSchemaBuilder, CommonLogLevel, CommonLogWithLevelFunction, CommonLogFunction, CommonLogger, };
|
|
74
|
-
export { is, _createPromiseDecorator,
|
|
77
|
+
export { is, _createPromiseDecorator, pMap, ErrorMode, pDefer, AggregatedError, pRetry, pRetryFn, pTimeout, pTimeoutFn, _tryCatch, _TryCatch, _stringifyAny, jsonSchema, JsonSchemaAnyBuilder, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.JsonSchemaAnyBuilder = exports.jsonSchema = exports._stringifyAny = exports._TryCatch = exports._tryCatch = exports.pTimeoutFn = exports.pTimeout = exports.pRetryFn = exports.pRetry = exports.AggregatedError = exports.pDefer = exports.ErrorMode = exports.pMap = exports._createPromiseDecorator = exports.is = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./array/array.util"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./lazy"), exports);
|
|
@@ -67,30 +67,13 @@ const stringifyAny_1 = require("./string/stringifyAny");
|
|
|
67
67
|
Object.defineProperty(exports, "_stringifyAny", { enumerable: true, get: function () { return stringifyAny_1._stringifyAny; } });
|
|
68
68
|
tslib_1.__exportStar(require("./time/time.util"), exports);
|
|
69
69
|
tslib_1.__exportStar(require("./is.util"), exports);
|
|
70
|
-
|
|
71
|
-
Object.defineProperty(exports, "END", { enumerable: true, get: function () { return types_1.END; } });
|
|
72
|
-
Object.defineProperty(exports, "SKIP", { enumerable: true, get: function () { return types_1.SKIP; } });
|
|
73
|
-
Object.defineProperty(exports, "_noop", { enumerable: true, get: function () { return types_1._noop; } });
|
|
74
|
-
Object.defineProperty(exports, "_objectKeys", { enumerable: true, get: function () { return types_1._objectKeys; } });
|
|
75
|
-
Object.defineProperty(exports, "_passNothingPredicate", { enumerable: true, get: function () { return types_1._passNothingPredicate; } });
|
|
76
|
-
Object.defineProperty(exports, "_passthroughMapper", { enumerable: true, get: function () { return types_1._passthroughMapper; } });
|
|
77
|
-
Object.defineProperty(exports, "_passthroughPredicate", { enumerable: true, get: function () { return types_1._passthroughPredicate; } });
|
|
78
|
-
Object.defineProperty(exports, "_passUndefinedMapper", { enumerable: true, get: function () { return types_1._passUndefinedMapper; } });
|
|
79
|
-
Object.defineProperty(exports, "_stringMapEntries", { enumerable: true, get: function () { return types_1._stringMapEntries; } });
|
|
80
|
-
Object.defineProperty(exports, "_stringMapValues", { enumerable: true, get: function () { return types_1._stringMapValues; } });
|
|
70
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
81
71
|
tslib_1.__exportStar(require("./unit/size.util"), exports);
|
|
82
72
|
const is_1 = require("./vendor/is");
|
|
83
73
|
Object.defineProperty(exports, "is", { enumerable: true, get: function () { return is_1.is; } });
|
|
84
|
-
|
|
85
|
-
Object.defineProperty(exports, "commonLoggerMinLevel", { enumerable: true, get: function () { return commonLogger_1.commonLoggerMinLevel; } });
|
|
86
|
-
Object.defineProperty(exports, "commonLoggerNoop", { enumerable: true, get: function () { return commonLogger_1.commonLoggerNoop; } });
|
|
87
|
-
Object.defineProperty(exports, "commonLogLevelNumber", { enumerable: true, get: function () { return commonLogger_1.commonLogLevelNumber; } });
|
|
88
|
-
Object.defineProperty(exports, "commonLoggerPipe", { enumerable: true, get: function () { return commonLogger_1.commonLoggerPipe; } });
|
|
89
|
-
Object.defineProperty(exports, "commonLoggerPrefix", { enumerable: true, get: function () { return commonLogger_1.commonLoggerPrefix; } });
|
|
90
|
-
Object.defineProperty(exports, "commonLoggerCreate", { enumerable: true, get: function () { return commonLogger_1.commonLoggerCreate; } });
|
|
74
|
+
tslib_1.__exportStar(require("./log/commonLogger"), exports);
|
|
91
75
|
tslib_1.__exportStar(require("./string/safeJsonStringify"), exports);
|
|
92
|
-
|
|
93
|
-
Object.defineProperty(exports, "PQueue", { enumerable: true, get: function () { return pQueue_1.PQueue; } });
|
|
76
|
+
tslib_1.__exportStar(require("./promise/pQueue"), exports);
|
|
94
77
|
tslib_1.__exportStar(require("./seq/seq"), exports);
|
|
95
78
|
tslib_1.__exportStar(require("./math/stack.util"), exports);
|
|
96
79
|
tslib_1.__exportStar(require("./string/leven"), exports);
|
package/dist/types.d.ts
CHANGED
|
@@ -194,3 +194,15 @@ export declare function _stringMapEntries<T>(m: StringMap<T>): [k: string, v: T]
|
|
|
194
194
|
export declare function _objectKeys<T extends AnyObject>(obj: T): (keyof T)[];
|
|
195
195
|
export declare type NullishValue = null | undefined;
|
|
196
196
|
export declare type FalsyValue = false | '' | 0 | null | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* Utility function that helps to cast *existing variable* to needed type T.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* try {} catch (err) {
|
|
202
|
+
* // err is unknown here
|
|
203
|
+
* _typeCast<AppError>(err)
|
|
204
|
+
* // now err is of type AppError
|
|
205
|
+
* err.data = {} // can be done, because it was casted
|
|
206
|
+
* }
|
|
207
|
+
*/
|
|
208
|
+
export declare function _typeCast<T>(v: any): asserts v is T;
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._passNothingPredicate = exports._passthroughPredicate = exports._noop = exports._passUndefinedMapper = exports._passthroughMapper = exports.SKIP = exports.END = void 0;
|
|
3
|
+
exports._typeCast = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._passNothingPredicate = exports._passthroughPredicate = exports._noop = exports._passUndefinedMapper = exports._passthroughMapper = exports.SKIP = exports.END = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Symbol to indicate END of Sequence.
|
|
6
6
|
*/
|
|
@@ -48,3 +48,16 @@ function _objectKeys(obj) {
|
|
|
48
48
|
return Object.keys(obj);
|
|
49
49
|
}
|
|
50
50
|
exports._objectKeys = _objectKeys;
|
|
51
|
+
/**
|
|
52
|
+
* Utility function that helps to cast *existing variable* to needed type T.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* try {} catch (err) {
|
|
56
|
+
* // err is unknown here
|
|
57
|
+
* _typeCast<AppError>(err)
|
|
58
|
+
* // now err is of type AppError
|
|
59
|
+
* err.data = {} // can be done, because it was casted
|
|
60
|
+
* }
|
|
61
|
+
*/
|
|
62
|
+
function _typeCast(v) { }
|
|
63
|
+
exports._typeCast = _typeCast;
|
|
@@ -96,3 +96,18 @@ export function _isHttpErrorObject(o) {
|
|
|
96
96
|
export function _isErrorObject(o) {
|
|
97
97
|
return (!!o && typeof o.name === 'string' && typeof o.message === 'string' && typeof o.data === 'object');
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Convenience function to safely add properties to Error's `data` object
|
|
101
|
+
* (even if it wasn't previously existing)
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
*
|
|
105
|
+
* try {} catch (err) {
|
|
106
|
+
* _errorDataAppend(err, {
|
|
107
|
+
* httpStatusCode: 401,
|
|
108
|
+
* })
|
|
109
|
+
* }
|
|
110
|
+
*/
|
|
111
|
+
export function _errorDataAppend(err, data) {
|
|
112
|
+
err.data = Object.assign(Object.assign({}, err.data), data);
|
|
113
|
+
}
|
package/dist-esm/index.js
CHANGED
|
@@ -49,12 +49,12 @@ export * from './string/string.util';
|
|
|
49
49
|
import { _stringifyAny } from './string/stringifyAny';
|
|
50
50
|
export * from './time/time.util';
|
|
51
51
|
export * from './is.util';
|
|
52
|
-
|
|
52
|
+
export * from './types';
|
|
53
53
|
export * from './unit/size.util';
|
|
54
54
|
import { is } from './vendor/is';
|
|
55
|
-
|
|
55
|
+
export * from './log/commonLogger';
|
|
56
56
|
export * from './string/safeJsonStringify';
|
|
57
|
-
|
|
57
|
+
export * from './promise/pQueue';
|
|
58
58
|
export * from './seq/seq';
|
|
59
59
|
export * from './math/stack.util';
|
|
60
60
|
export * from './string/leven';
|
|
@@ -63,4 +63,4 @@ export * from './datetime/localTime';
|
|
|
63
63
|
export * from './datetime/dateInterval';
|
|
64
64
|
export * from './datetime/timeInterval';
|
|
65
65
|
import { ISODayOfWeek, } from './datetime/localTime';
|
|
66
|
-
export { is, _createPromiseDecorator,
|
|
66
|
+
export { is, _createPromiseDecorator, pMap, ErrorMode, pDefer, AggregatedError, pRetry, pRetryFn, pTimeout, pTimeoutFn, _tryCatch, _TryCatch, _stringifyAny, jsonSchema, JsonSchemaAnyBuilder, };
|
package/dist-esm/types.js
CHANGED
|
@@ -37,3 +37,15 @@ export function _stringMapEntries(m) {
|
|
|
37
37
|
export function _objectKeys(obj) {
|
|
38
38
|
return Object.keys(obj);
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Utility function that helps to cast *existing variable* to needed type T.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* try {} catch (err) {
|
|
45
|
+
* // err is unknown here
|
|
46
|
+
* _typeCast<AppError>(err)
|
|
47
|
+
* // now err is of type AppError
|
|
48
|
+
* err.data = {} // can be done, because it was casted
|
|
49
|
+
* }
|
|
50
|
+
*/
|
|
51
|
+
export function _typeCast(v) { }
|
package/package.json
CHANGED
package/src/error/error.util.ts
CHANGED
|
@@ -145,3 +145,22 @@ export function _isErrorObject(o: any): o is ErrorObject {
|
|
|
145
145
|
!!o && typeof o.name === 'string' && typeof o.message === 'string' && typeof o.data === 'object'
|
|
146
146
|
)
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Convenience function to safely add properties to Error's `data` object
|
|
151
|
+
* (even if it wasn't previously existing)
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
*
|
|
155
|
+
* try {} catch (err) {
|
|
156
|
+
* _errorDataAppend(err, {
|
|
157
|
+
* httpStatusCode: 401,
|
|
158
|
+
* })
|
|
159
|
+
* }
|
|
160
|
+
*/
|
|
161
|
+
export function _errorDataAppend(err: any, data: ErrorData): void {
|
|
162
|
+
err.data = {
|
|
163
|
+
...err.data,
|
|
164
|
+
...data,
|
|
165
|
+
}
|
|
166
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -137,33 +137,20 @@ import {
|
|
|
137
137
|
AbortablePredicate,
|
|
138
138
|
NullishValue,
|
|
139
139
|
FalsyValue,
|
|
140
|
-
END,
|
|
141
|
-
SKIP,
|
|
142
|
-
_noop,
|
|
143
|
-
_objectKeys,
|
|
144
|
-
_passNothingPredicate,
|
|
145
|
-
_passthroughMapper,
|
|
146
|
-
_passthroughPredicate,
|
|
147
|
-
_passUndefinedMapper,
|
|
148
|
-
_stringMapEntries,
|
|
149
|
-
_stringMapValues,
|
|
150
140
|
} from './types'
|
|
141
|
+
export * from './types'
|
|
151
142
|
export * from './unit/size.util'
|
|
152
143
|
import { is } from './vendor/is'
|
|
153
144
|
import {
|
|
154
145
|
CommonLogLevel,
|
|
155
146
|
CommonLogFunction,
|
|
156
147
|
CommonLogger,
|
|
157
|
-
commonLoggerMinLevel,
|
|
158
|
-
commonLoggerNoop,
|
|
159
|
-
commonLogLevelNumber,
|
|
160
|
-
commonLoggerPipe,
|
|
161
|
-
commonLoggerPrefix,
|
|
162
148
|
CommonLogWithLevelFunction,
|
|
163
|
-
commonLoggerCreate,
|
|
164
149
|
} from './log/commonLogger'
|
|
150
|
+
export * from './log/commonLogger'
|
|
165
151
|
export * from './string/safeJsonStringify'
|
|
166
|
-
import {
|
|
152
|
+
import { PQueueCfg } from './promise/pQueue'
|
|
153
|
+
export * from './promise/pQueue'
|
|
167
154
|
export * from './seq/seq'
|
|
168
155
|
export * from './math/stack.util'
|
|
169
156
|
export * from './string/leven'
|
|
@@ -296,15 +283,7 @@ export type {
|
|
|
296
283
|
export {
|
|
297
284
|
is,
|
|
298
285
|
_createPromiseDecorator,
|
|
299
|
-
_stringMapValues,
|
|
300
|
-
_stringMapEntries,
|
|
301
|
-
_objectKeys,
|
|
302
286
|
pMap,
|
|
303
|
-
_passthroughMapper,
|
|
304
|
-
_passUndefinedMapper,
|
|
305
|
-
_passthroughPredicate,
|
|
306
|
-
_passNothingPredicate,
|
|
307
|
-
_noop,
|
|
308
287
|
ErrorMode,
|
|
309
288
|
pDefer,
|
|
310
289
|
AggregatedError,
|
|
@@ -317,13 +296,4 @@ export {
|
|
|
317
296
|
_stringifyAny,
|
|
318
297
|
jsonSchema,
|
|
319
298
|
JsonSchemaAnyBuilder,
|
|
320
|
-
commonLoggerMinLevel,
|
|
321
|
-
commonLoggerNoop,
|
|
322
|
-
commonLogLevelNumber,
|
|
323
|
-
commonLoggerPipe,
|
|
324
|
-
commonLoggerPrefix,
|
|
325
|
-
commonLoggerCreate,
|
|
326
|
-
PQueue,
|
|
327
|
-
END,
|
|
328
|
-
SKIP,
|
|
329
299
|
}
|
package/src/types.ts
CHANGED
|
@@ -267,3 +267,16 @@ export function _objectKeys<T extends AnyObject>(obj: T): (keyof T)[] {
|
|
|
267
267
|
|
|
268
268
|
export type NullishValue = null | undefined
|
|
269
269
|
export type FalsyValue = false | '' | 0 | null | undefined
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Utility function that helps to cast *existing variable* to needed type T.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* try {} catch (err) {
|
|
276
|
+
* // err is unknown here
|
|
277
|
+
* _typeCast<AppError>(err)
|
|
278
|
+
* // now err is of type AppError
|
|
279
|
+
* err.data = {} // can be done, because it was casted
|
|
280
|
+
* }
|
|
281
|
+
*/
|
|
282
|
+
export function _typeCast<T>(v: any): asserts v is T {}
|