@naturalcycles/js-lib 14.109.0 → 14.110.0
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/array/array.util.d.ts +2 -2
- package/dist/datetime/dateInterval.d.ts +2 -1
- package/dist/datetime/localDate.d.ts +1 -1
- package/dist/datetime/localTime.d.ts +3 -2
- package/dist/datetime/timeInterval.d.ts +4 -3
- package/dist/decorators/asyncMemo.decorator.d.ts +2 -2
- package/dist/decorators/debounce.d.ts +1 -1
- package/dist/decorators/debounce.decorator.d.ts +1 -1
- package/dist/decorators/decorator.util.d.ts +1 -1
- package/dist/decorators/logMethod.decorator.d.ts +1 -1
- package/dist/decorators/memo.decorator.d.ts +2 -2
- package/dist/decorators/memo.util.d.ts +1 -1
- package/dist/decorators/memoFn.d.ts +2 -2
- package/dist/decorators/memoFnAsync.d.ts +2 -2
- package/dist/decorators/memoSimple.decorator.d.ts +1 -1
- package/dist/decorators/retry.decorator.d.ts +1 -1
- package/dist/decorators/timeout.decorator.d.ts +1 -1
- package/dist/enum.util.d.ts +1 -1
- package/dist/error/app.error.d.ts +1 -1
- package/dist/error/assert.d.ts +1 -1
- package/dist/error/error.util.d.ts +4 -3
- package/dist/error/http.error.d.ts +1 -1
- package/dist/error/try.d.ts +1 -1
- package/dist/error/tryCatch.d.ts +2 -2
- package/dist/index.d.ts +20 -23
- package/dist/index.js +20 -26
- package/dist/is.util.d.ts +2 -2
- package/dist/json-schema/from-data/generateJsonSchemaFromData.d.ts +2 -2
- package/dist/json-schema/jsonSchema.cnst.d.ts +1 -1
- package/dist/json-schema/jsonSchema.model.d.ts +2 -2
- package/dist/json-schema/jsonSchema.util.d.ts +3 -2
- package/dist/json-schema/jsonSchemaBuilder.d.ts +2 -2
- package/dist/json-schema/jsonSchemas.d.ts +1 -1
- package/dist/lazy.d.ts +1 -1
- package/dist/object/object.util.d.ts +2 -2
- package/dist/object/sortObject.d.ts +1 -1
- package/dist/promise/pFilter.d.ts +1 -1
- package/dist/promise/pMap.d.ts +2 -1
- package/dist/promise/pQueue.d.ts +1 -1
- package/dist/promise/pRetry.d.ts +1 -1
- package/dist/promise/pTimeout.d.ts +2 -2
- package/dist/seq/seq.d.ts +2 -1
- package/dist/string/safeJsonStringify.d.ts +1 -1
- package/dist/string/stringifyAny.d.ts +1 -1
- package/dist/string/url.util.d.ts +1 -1
- package/dist/typeFest.d.ts +40 -3
- package/dist/types.d.ts +5 -13
- package/dist-esm/error/error.util.js +1 -1
- package/dist-esm/index.js +20 -12
- package/dist-esm/json-schema/from-data/generateJsonSchemaFromData.js +1 -1
- package/dist-esm/json-schema/jsonSchemaBuilder.js +1 -1
- package/dist-esm/seq/seq.js +1 -1
- package/package.json +2 -2
- package/src/array/array.util.ts +2 -2
- package/src/datetime/dateInterval.ts +2 -1
- package/src/datetime/localDate.ts +1 -1
- package/src/datetime/localTime.ts +3 -2
- package/src/datetime/timeInterval.ts +4 -3
- package/src/decorators/asyncMemo.decorator.ts +4 -3
- package/src/decorators/debounce.decorator.ts +2 -1
- package/src/decorators/debounce.ts +1 -1
- package/src/decorators/decorator.util.ts +1 -1
- package/src/decorators/logMethod.decorator.ts +2 -1
- package/src/decorators/memo.decorator.ts +4 -3
- package/src/decorators/memo.util.ts +1 -1
- package/src/decorators/memoFn.ts +3 -2
- package/src/decorators/memoFnAsync.ts +3 -2
- package/src/decorators/memoSimple.decorator.ts +3 -2
- package/src/decorators/retry.decorator.ts +2 -1
- package/src/decorators/timeout.decorator.ts +2 -1
- package/src/enum.util.ts +1 -1
- package/src/error/app.error.ts +1 -1
- package/src/error/assert.ts +2 -1
- package/src/error/error.util.ts +6 -6
- package/src/error/http.error.ts +1 -1
- package/src/error/try.ts +1 -1
- package/src/error/tryCatch.ts +3 -2
- package/src/index.ts +20 -244
- package/src/is.util.ts +2 -2
- package/src/json-schema/from-data/generateJsonSchemaFromData.ts +5 -4
- package/src/json-schema/jsonSchema.cnst.ts +1 -1
- package/src/json-schema/jsonSchema.model.ts +2 -2
- package/src/json-schema/jsonSchema.util.ts +3 -3
- package/src/json-schema/jsonSchemaBuilder.ts +3 -5
- package/src/json-schema/jsonSchemas.ts +1 -1
- package/src/lazy.ts +1 -1
- package/src/object/object.util.ts +2 -2
- package/src/object/sortObject.ts +2 -1
- package/src/promise/pFilter.ts +1 -1
- package/src/promise/pMap.ts +2 -1
- package/src/promise/pQueue.ts +3 -2
- package/src/promise/pRetry.ts +2 -1
- package/src/promise/pTimeout.ts +2 -2
- package/src/seq/seq.ts +2 -3
- package/src/string/safeJsonStringify.ts +1 -1
- package/src/string/stringifyAny.ts +1 -1
- package/src/string/url.util.ts +1 -1
- package/src/typeFest.ts +57 -7
- package/src/types.ts +8 -20
package/dist/typeFest.d.ts
CHANGED
|
@@ -10,6 +10,19 @@ export declare type Primitive = null | undefined | string | number | boolean | s
|
|
|
10
10
|
export declare type Simplify<T> = {
|
|
11
11
|
[KeyType in keyof T]: T[KeyType];
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
Returns a boolean for whether the two given types are equal.
|
|
15
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
16
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
17
|
+
*/
|
|
18
|
+
export declare type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
|
|
19
|
+
/**
|
|
20
|
+
* Filter out keys from an object.
|
|
21
|
+
* Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
22
|
+
* Returns `never` if `Key` extends `Exclude`.
|
|
23
|
+
* Returns `Key` otherwise.
|
|
24
|
+
*/
|
|
25
|
+
declare type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : KeyType extends ExcludeType ? never : KeyType;
|
|
13
26
|
/**
|
|
14
27
|
Create a type from an object type without certain keys.
|
|
15
28
|
|
|
@@ -33,7 +46,9 @@ export declare type Simplify<T> = {
|
|
|
33
46
|
|
|
34
47
|
@category Utilities
|
|
35
48
|
*/
|
|
36
|
-
export declare type Except<ObjectType, KeysType extends keyof ObjectType> =
|
|
49
|
+
export declare type Except<ObjectType, KeysType extends keyof ObjectType> = {
|
|
50
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
51
|
+
};
|
|
37
52
|
/**
|
|
38
53
|
Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
|
|
39
54
|
|
|
@@ -82,7 +97,27 @@ interface ReadonlySetDeep<ItemType> extends ReadonlySet<ReadonlyDeep<ItemType>>
|
|
|
82
97
|
declare type ReadonlyObjectDeep<ObjectType extends object> = {
|
|
83
98
|
readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>;
|
|
84
99
|
};
|
|
85
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
102
|
+
* This is the counterpart of `OmitIndexSignature`.
|
|
103
|
+
* When you use a type that will iterate through an object that has indexed keys and explicitly defined keys you end up with a type where only the indexed keys are kept. This is because `keyof` of an indexed type always returns `string | number | symbol`, because every key is possible in that object. With this type, you can save the indexed keys and reinject them later, like in the second example below.
|
|
104
|
+
*/
|
|
105
|
+
export declare type PickIndexSignature<ObjectType> = {
|
|
106
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType];
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
110
|
+
* This is the counterpart of `PickIndexSignature`.
|
|
111
|
+
* Use-cases:
|
|
112
|
+
* - Remove overly permissive signatures from third-party types.
|
|
113
|
+
*
|
|
114
|
+
* This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
115
|
+
* It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
116
|
+
* (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
117
|
+
*/
|
|
118
|
+
export declare type OmitIndexSignature<ObjectType> = {
|
|
119
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
|
|
120
|
+
};
|
|
86
121
|
/**
|
|
87
122
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
88
123
|
|
|
@@ -104,7 +139,9 @@ declare type Merge_<FirstType, SecondType> = Except<FirstType, Extract<keyof Fir
|
|
|
104
139
|
|
|
105
140
|
@category Utilities
|
|
106
141
|
*/
|
|
107
|
-
export declare type Merge<
|
|
142
|
+
export declare type Merge<Destination, Source> = {
|
|
143
|
+
[Key in keyof OmitIndexSignature<Destination & Source>]: Key extends keyof Source ? Source[Key] : Key extends keyof Destination ? Destination[Key] : never;
|
|
144
|
+
} & PickIndexSignature<Destination & Source>;
|
|
108
145
|
/**
|
|
109
146
|
Create a type that represents either the value or the value wrapped in `PromiseLike`.
|
|
110
147
|
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Promisable } from './typeFest';
|
|
2
2
|
/**
|
|
3
3
|
* Map from String to String (or <T>).
|
|
4
4
|
*
|
|
@@ -7,14 +7,6 @@ import { Except, Merge, Promisable } from './typeFest';
|
|
|
7
7
|
export interface StringMap<T = string> {
|
|
8
8
|
[k: string | number]: T | undefined;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Object to be passed to pProps to resolve all promises into properties.
|
|
12
|
-
*
|
|
13
|
-
* Alternative: Record<String, Promise<any>>
|
|
14
|
-
*/
|
|
15
|
-
export interface PromiseMap {
|
|
16
|
-
[prop: string]: Promise<any> | undefined;
|
|
17
|
-
}
|
|
18
10
|
/**
|
|
19
11
|
* Convenience shorthand for `Record<string, any>`.
|
|
20
12
|
* Because `object` type is not safe/recommended to be used (e.g discouraged by eslint-typescript due to: https://github.com/microsoft/TypeScript/issues/21732)
|
|
@@ -56,10 +48,10 @@ export interface SavedDBEntity<ID extends string | number = string> {
|
|
|
56
48
|
* When it's known to be saved - `SavedDBEntity` interface can be used instead.
|
|
57
49
|
*/
|
|
58
50
|
export declare type BaseDBEntity<ID extends string | number = string> = Partial<SavedDBEntity<ID>>;
|
|
59
|
-
export declare type Saved<T extends Partial<ObjectWithId>> =
|
|
60
|
-
export declare type Unsaved<T extends Partial<ObjectWithId>> =
|
|
61
|
-
export declare type UnsavedId<T extends Partial<ObjectWithId>> =
|
|
62
|
-
id
|
|
51
|
+
export declare type Saved<T extends Partial<ObjectWithId>> = Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity<NonNullable<T['id']>>;
|
|
52
|
+
export declare type Unsaved<T extends Partial<ObjectWithId>> = Omit<T, 'id' | 'created' | 'updated'> & BaseDBEntity<NonNullable<T['id']>>;
|
|
53
|
+
export declare type UnsavedId<T extends Partial<ObjectWithId>> = Omit<T, 'id'> & {
|
|
54
|
+
id?: T['id'];
|
|
63
55
|
};
|
|
64
56
|
/**
|
|
65
57
|
* Convenience type shorthand.
|
package/dist-esm/index.js
CHANGED
|
@@ -2,13 +2,14 @@ export * from './array/array.util';
|
|
|
2
2
|
export * from './lazy';
|
|
3
3
|
export * from './string/url.util';
|
|
4
4
|
export * from './array/range';
|
|
5
|
-
|
|
5
|
+
export * from './decorators/createPromiseDecorator';
|
|
6
6
|
export * from './decorators/debounce';
|
|
7
7
|
export * from './decorators/debounce.decorator';
|
|
8
8
|
export * from './decorators/decorator.util';
|
|
9
9
|
export * from './decorators/logMethod.decorator';
|
|
10
10
|
export * from './decorators/memo.decorator';
|
|
11
11
|
export * from './decorators/asyncMemo.decorator';
|
|
12
|
+
export * from './decorators/memo.util';
|
|
12
13
|
export * from './decorators/memoFn';
|
|
13
14
|
export * from './decorators/memoFnAsync';
|
|
14
15
|
export * from './decorators/retry.decorator';
|
|
@@ -16,15 +17,18 @@ export * from './decorators/timeout.decorator';
|
|
|
16
17
|
export * from './error/app.error';
|
|
17
18
|
export * from './error/assert';
|
|
18
19
|
export * from './enum.util';
|
|
20
|
+
export * from './error/error.model';
|
|
19
21
|
export * from './error/error.util';
|
|
20
|
-
|
|
22
|
+
export * from './error/errorMode';
|
|
21
23
|
export * from './error/http.error';
|
|
22
24
|
export * from './error/try';
|
|
23
|
-
|
|
25
|
+
export * from './error/tryCatch';
|
|
24
26
|
export * from './json-schema/from-data/generateJsonSchemaFromData';
|
|
25
27
|
export * from './json-schema/jsonSchema.cnst';
|
|
28
|
+
export * from './json-schema/jsonSchema.model';
|
|
26
29
|
export * from './json-schema/jsonSchema.util';
|
|
27
|
-
|
|
30
|
+
export * from './json-schema/jsonSchemaBuilder';
|
|
31
|
+
export * from './json-schema/jsonSchemaBuilder';
|
|
28
32
|
export * from './math/math.util';
|
|
29
33
|
export * from './math/sma';
|
|
30
34
|
export * from './number/createDeterministicRandom';
|
|
@@ -33,25 +37,26 @@ export * from './object/deepEquals';
|
|
|
33
37
|
export * from './object/object.util';
|
|
34
38
|
export * from './object/sortObject';
|
|
35
39
|
export * from './object/sortObjectDeep';
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
export * from './promise/AggregatedError';
|
|
41
|
+
export * from './promise/pDefer';
|
|
38
42
|
export * from './promise/pDelay';
|
|
39
43
|
export * from './promise/pFilter';
|
|
40
44
|
export * from './promise/pHang';
|
|
41
|
-
|
|
45
|
+
export * from './promise/pMap';
|
|
42
46
|
export * from './promise/pProps';
|
|
43
|
-
|
|
47
|
+
export * from './promise/pRetry';
|
|
44
48
|
export * from './promise/pState';
|
|
45
|
-
|
|
49
|
+
export * from './promise/pTimeout';
|
|
46
50
|
export * from './string/case';
|
|
47
51
|
export * from './string/json.util';
|
|
48
52
|
export * from './string/string.util';
|
|
49
53
|
export * from './string/readingTime';
|
|
50
54
|
export * from './string/escape';
|
|
51
55
|
export * from './string/pupa';
|
|
52
|
-
|
|
56
|
+
export * from './string/stringifyAny';
|
|
53
57
|
export * from './time/time.util';
|
|
54
58
|
export * from './is.util';
|
|
59
|
+
export * from './typeFest';
|
|
55
60
|
export * from './types';
|
|
56
61
|
export * from './unit/size.util';
|
|
57
62
|
import { is } from './vendor/is';
|
|
@@ -65,5 +70,8 @@ export * from './datetime/localDate';
|
|
|
65
70
|
export * from './datetime/localTime';
|
|
66
71
|
export * from './datetime/dateInterval';
|
|
67
72
|
export * from './datetime/timeInterval';
|
|
68
|
-
|
|
69
|
-
export
|
|
73
|
+
export * from './datetime/localDate';
|
|
74
|
+
export * from './datetime/localTime';
|
|
75
|
+
export * from './datetime/dateInterval';
|
|
76
|
+
export * from './datetime/timeInterval';
|
|
77
|
+
export { is };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _uniq } from '../array/array.util';
|
|
2
|
-
import { mergeJsonSchemaObjects, _deepCopy, _sortObject
|
|
2
|
+
import { mergeJsonSchemaObjects, _deepCopy, _sortObject } from '../index';
|
|
3
3
|
import { JSON_SCHEMA_ORDER } from './jsonSchema.cnst';
|
|
4
4
|
/**
|
|
5
5
|
* Fluent (chainable) API to manually create Json Schemas.
|
package/dist-esm/seq/seq.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.110.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"build-prod": "build-prod-esm-cjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@naturalcycles/time-lib": "^3.5.1",
|
|
18
18
|
"@types/node": "^18.0.0",
|
|
19
19
|
"expect-type": "^0.13.0",
|
|
20
|
-
"jest": "^
|
|
20
|
+
"jest": "^29.0.0",
|
|
21
21
|
"prettier": "^2.1.2",
|
|
22
22
|
"rxjs": "^7.0.1",
|
|
23
23
|
"vuepress": "^1.7.1",
|
package/src/array/array.util.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _isNotNullish } from '../is.util'
|
|
2
|
-
import { RecursiveArray } from '../lodash.types'
|
|
3
|
-
import { FalsyValue, Mapper, Predicate, StringMap } from '../types'
|
|
2
|
+
import type { RecursiveArray } from '../lodash.types'
|
|
3
|
+
import type { FalsyValue, Mapper, Predicate, StringMap } from '../types'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates an array of elements split into groups the length of size. If collection can’t be split evenly, the
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Inclusiveness,
|
|
1
|
+
import type { Inclusiveness, LocalDateConfig, LocalDateUnit } from './localDate'
|
|
2
|
+
import { LocalDate } from './localDate'
|
|
2
3
|
|
|
3
4
|
export type DateIntervalConfig = DateInterval | DateIntervalString
|
|
4
5
|
export type DateIntervalString = string
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { _assert } from '../error/assert'
|
|
2
2
|
import { _ms } from '../time/time.util'
|
|
3
|
-
import {
|
|
3
|
+
import type {
|
|
4
4
|
IsoDateString,
|
|
5
5
|
IsoDateTimeString,
|
|
6
6
|
UnixTimestampMillisNumber,
|
|
7
7
|
UnixTimestampNumber,
|
|
8
8
|
} from '../types'
|
|
9
|
-
import { Inclusiveness
|
|
9
|
+
import type { Inclusiveness } from './localDate'
|
|
10
|
+
import { LocalDate } from './localDate'
|
|
10
11
|
|
|
11
12
|
export type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second'
|
|
12
13
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { UnixTimestampNumber } from '../types'
|
|
2
|
-
import { Inclusiveness } from './localDate'
|
|
3
|
-
import {
|
|
1
|
+
import type { UnixTimestampNumber } from '../types'
|
|
2
|
+
import type { Inclusiveness } from './localDate'
|
|
3
|
+
import type { LocalTimeConfig } from './localTime'
|
|
4
|
+
import { LocalTime } from './localTime'
|
|
4
5
|
|
|
5
6
|
export type TimeIntervalConfig = TimeInterval | TimeIntervalString
|
|
6
7
|
export type TimeIntervalString = string
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { CommonLogger } from '../log/commonLogger'
|
|
1
|
+
import type { CommonLogger } from '../log/commonLogger'
|
|
2
2
|
import { _since } from '../time/time.util'
|
|
3
|
-
import { AnyObject } from '../types'
|
|
3
|
+
import type { AnyObject } from '../types'
|
|
4
4
|
import { _getArgsSignature, _getMethodSignature, _getTargetMethodSignature } from './decorator.util'
|
|
5
|
-
import { AsyncMemoCache
|
|
5
|
+
import type { AsyncMemoCache } from './memo.util'
|
|
6
|
+
import { jsonMemoSerializer, MapMemoCache } from './memo.util'
|
|
6
7
|
|
|
7
8
|
export interface AsyncMemoOptions {
|
|
8
9
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DebounceOptions, ThrottleOptions
|
|
1
|
+
import type { DebounceOptions, ThrottleOptions } from './debounce'
|
|
2
|
+
import { _debounce, _throttle } from './debounce'
|
|
2
3
|
|
|
3
4
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4
5
|
export function _Debounce(wait: number, opt: DebounceOptions = {}): MethodDecorator {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CommonLogger } from '..'
|
|
2
|
+
import { SimpleMovingAverage, _stringifyAny, _assert } from '..'
|
|
2
3
|
import { _ms } from '../time/time.util'
|
|
3
4
|
import { _getArgsSignature, _getMethodSignature } from './decorator.util'
|
|
4
5
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { CommonLogger } from '../log/commonLogger'
|
|
1
|
+
import type { CommonLogger } from '../log/commonLogger'
|
|
2
2
|
import { _since } from '../time/time.util'
|
|
3
|
-
import { AnyObject } from '../types'
|
|
3
|
+
import type { AnyObject } from '../types'
|
|
4
4
|
import { _getArgsSignature, _getMethodSignature, _getTargetMethodSignature } from './decorator.util'
|
|
5
|
-
import {
|
|
5
|
+
import type { MemoCache } from './memo.util'
|
|
6
|
+
import { jsonMemoSerializer, MapMemoCache } from './memo.util'
|
|
6
7
|
|
|
7
8
|
export interface MemoOptions {
|
|
8
9
|
/**
|
package/src/decorators/memoFn.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { _since } from '../time/time.util'
|
|
2
2
|
import { _getArgsSignature } from './decorator.util'
|
|
3
|
-
import { MemoOptions } from './memo.decorator'
|
|
4
|
-
import {
|
|
3
|
+
import type { MemoOptions } from './memo.decorator'
|
|
4
|
+
import type { MemoCache } from './memo.util'
|
|
5
|
+
import { jsonMemoSerializer, MapMemoCache } from './memo.util'
|
|
5
6
|
|
|
6
7
|
export interface MemoizedFunction {
|
|
7
8
|
cache: MemoCache
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { _since } from '../time/time.util'
|
|
2
|
-
import { AsyncMemoOptions } from './asyncMemo.decorator'
|
|
2
|
+
import type { AsyncMemoOptions } from './asyncMemo.decorator'
|
|
3
3
|
import { _getArgsSignature } from './decorator.util'
|
|
4
|
-
import { AsyncMemoCache
|
|
4
|
+
import type { AsyncMemoCache } from './memo.util'
|
|
5
|
+
import { jsonMemoSerializer, MapMemoCache } from './memo.util'
|
|
5
6
|
|
|
6
7
|
export interface MemoizedAsyncFunction {
|
|
7
8
|
cache: AsyncMemoCache
|
|
@@ -11,9 +11,10 @@ Otherwise resorts to JSON.stringify.
|
|
|
11
11
|
Benchmark shows similar perf for ObjectCache and MapCache.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { CommonLogger } from '../log/commonLogger'
|
|
14
|
+
import type { CommonLogger } from '../log/commonLogger'
|
|
15
15
|
import { _getArgsSignature, _getTargetMethodSignature } from './decorator.util'
|
|
16
|
-
import {
|
|
16
|
+
import type { MemoCache } from './memo.util'
|
|
17
|
+
import { jsonMemoSerializer, MapMemoCache } from './memo.util'
|
|
17
18
|
|
|
18
19
|
export interface MemoOpts {
|
|
19
20
|
logHit?: boolean
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _assert } from '../error/assert'
|
|
2
|
-
import {
|
|
2
|
+
import type { PTimeoutOptions } from '../promise/pTimeout'
|
|
3
|
+
import { pTimeout } from '../promise/pTimeout'
|
|
3
4
|
import { _getMethodSignature } from './decorator.util'
|
|
4
5
|
|
|
5
6
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
package/src/enum.util.ts
CHANGED
package/src/error/app.error.ts
CHANGED
package/src/error/assert.ts
CHANGED
package/src/error/error.util.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AppError,
|
|
1
|
+
import type {
|
|
3
2
|
ErrorData,
|
|
4
3
|
ErrorObject,
|
|
5
4
|
HttpErrorData,
|
|
6
5
|
HttpErrorResponse,
|
|
7
6
|
StringifyAnyOptions,
|
|
8
|
-
_jsonParseIfPossible,
|
|
9
|
-
_stringifyAny,
|
|
10
7
|
Class,
|
|
11
8
|
} from '..'
|
|
9
|
+
import { AppError, _jsonParseIfPossible, _stringifyAny } from '..'
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Useful to ensure that error in `catch (err) { ... }`
|
|
@@ -89,11 +87,13 @@ export function _errorToErrorObject<DATA_TYPE extends ErrorData = ErrorData>(
|
|
|
89
87
|
return obj
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
export function _errorObjectToAppError<DATA_TYPE
|
|
90
|
+
export function _errorObjectToAppError<DATA_TYPE extends ErrorData>(
|
|
91
|
+
o: ErrorObject<DATA_TYPE>,
|
|
92
|
+
): AppError<DATA_TYPE> {
|
|
93
93
|
return _errorObjectToError(o, AppError)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
export function _errorObjectToError<DATA_TYPE, ERROR_TYPE extends Error>(
|
|
96
|
+
export function _errorObjectToError<DATA_TYPE extends ErrorData, ERROR_TYPE extends Error>(
|
|
97
97
|
o: ErrorObject<DATA_TYPE>,
|
|
98
98
|
errorClass: Class<ERROR_TYPE> = Error as any,
|
|
99
99
|
): ERROR_TYPE {
|
package/src/error/http.error.ts
CHANGED
package/src/error/try.ts
CHANGED
package/src/error/tryCatch.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { CommonLogger } from '../index'
|
|
2
|
+
import { _anyToError, _since, _stringifyAny } from '../index'
|
|
3
|
+
import type { AnyFunction } from '../types'
|
|
3
4
|
|
|
4
5
|
export interface TryCatchOptions {
|
|
5
6
|
/**
|