@augment-vir/common 31.68.1 → 31.68.3
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type NoInputsFunction
|
|
1
|
+
import { type NoInputsFunction } from '@augment-vir/core';
|
|
2
|
+
import { type RequireOneOrNone } from 'type-fest';
|
|
2
3
|
/**
|
|
3
4
|
* Options for {@link wrapInTry}.
|
|
4
5
|
*
|
|
@@ -6,7 +7,7 @@ import { type NoInputsFunction, type PartialWithUndefined } from '@augment-vir/c
|
|
|
6
7
|
* @category Package : @augment-vir/common
|
|
7
8
|
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
8
9
|
*/
|
|
9
|
-
export type WrapInTryOptions<FallbackValue> =
|
|
10
|
+
export type WrapInTryOptions<FallbackValue> = RequireOneOrNone<{
|
|
10
11
|
/**
|
|
11
12
|
* Call this function if the callback passed to {@link wrapInTry} throws an error. The thrown
|
|
12
13
|
* error is passed to this function. If a `fallbackValue` option is also provided, it will be
|
|
@@ -29,18 +30,18 @@ export declare function wrapInTry<Value>(callback: NoInputsFunction<Value>, opti
|
|
|
29
30
|
}): Error | Value;
|
|
30
31
|
export declare function wrapInTry<Value extends Promise<any>, FallbackValue = undefined>(callback: NoInputsFunction<Value>, options: {
|
|
31
32
|
handleError: (error: unknown) => FallbackValue;
|
|
32
|
-
fallbackValue?:
|
|
33
|
+
fallbackValue?: never;
|
|
33
34
|
}): Promise<Awaited<FallbackValue> | Awaited<Value>>;
|
|
34
35
|
export declare function wrapInTry<Value, FallbackValue = undefined>(callback: NoInputsFunction<Value>, options: {
|
|
35
36
|
handleError: (error: unknown) => FallbackValue;
|
|
36
|
-
fallbackValue?:
|
|
37
|
+
fallbackValue?: never;
|
|
37
38
|
}): FallbackValue | Value;
|
|
38
39
|
export declare function wrapInTry<Value extends Promise<any>, FallbackValue = undefined>(callback: NoInputsFunction<Value>, options: {
|
|
39
|
-
handleError?:
|
|
40
|
+
handleError?: never;
|
|
40
41
|
fallbackValue: FallbackValue;
|
|
41
42
|
}): Promise<Awaited<FallbackValue> | Awaited<Value>>;
|
|
42
43
|
export declare function wrapInTry<Value, FallbackValue = undefined>(callback: NoInputsFunction<Value>, options: {
|
|
43
|
-
handleError?:
|
|
44
|
+
handleError?: never;
|
|
44
45
|
fallbackValue: FallbackValue;
|
|
45
46
|
}): FallbackValue | Value;
|
|
46
47
|
export declare function wrapInTry<Value extends Promise<any>, FallbackValue = undefined>(callback: NoInputsFunction<Value>, options?: WrapInTryOptions<FallbackValue> | undefined): Promise<FallbackValue | Value | Error>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
|
-
import { ensureError
|
|
2
|
+
import { ensureError } from '@augment-vir/core';
|
|
3
3
|
/**
|
|
4
4
|
* Calls the callback and returns its output. If the callback throws an error, it is handled in the
|
|
5
5
|
* following ways:
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function mapObject<const OriginalObject, const NewKey extends PropertyKey, const NewValue>(inputObject: OriginalObject, mapCallback: (originalKey: keyof OriginalObject, originalValue:
|
|
1
|
+
import { type CompleteValues, type MaybePromise } from '@augment-vir/core';
|
|
2
|
+
export declare function mapObject<const OriginalObject, const NewKey extends PropertyKey, const NewValue>(inputObject: OriginalObject, mapCallback: (originalKey: keyof OriginalObject, originalValue: CompleteValues<OriginalObject>, originalObject: OriginalObject) => Promise<{
|
|
3
3
|
key: NewKey;
|
|
4
4
|
value: NewValue;
|
|
5
5
|
} | undefined>): Promise<Record<NewKey, NewValue>>;
|
|
6
|
-
export declare function mapObject<const OriginalObject, const NewKey extends PropertyKey, const NewValue>(inputObject: OriginalObject, mapCallback: (originalKey: keyof OriginalObject, originalValue:
|
|
6
|
+
export declare function mapObject<const OriginalObject, const NewKey extends PropertyKey, const NewValue>(inputObject: OriginalObject, mapCallback: (originalKey: keyof OriginalObject, originalValue: CompleteValues<OriginalObject>, originalObject: OriginalObject) => {
|
|
7
7
|
key: NewKey;
|
|
8
8
|
value: NewValue;
|
|
9
9
|
} | undefined): Record<NewKey, NewValue>;
|
|
10
|
-
export declare function mapObject<const OriginalObject, const NewKey extends PropertyKey, const NewValue>(inputObject: OriginalObject, mapCallback: (originalKey: keyof OriginalObject, originalValue:
|
|
10
|
+
export declare function mapObject<const OriginalObject, const NewKey extends PropertyKey, const NewValue>(inputObject: OriginalObject, mapCallback: (originalKey: keyof OriginalObject, originalValue: CompleteValues<OriginalObject>, originalObject: OriginalObject) => MaybePromise<{
|
|
11
11
|
key: NewKey;
|
|
12
12
|
value: NewValue;
|
|
13
13
|
} | undefined>): MaybePromise<Record<NewKey, NewValue>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CompleteValues, type EnumBaseType, type MaybePromise } from '@augment-vir/core';
|
|
2
2
|
/**
|
|
3
3
|
* Creates an object that maps all values of an enum to the provided `Values` type.
|
|
4
4
|
*
|
|
@@ -6,6 +6,6 @@ import { type EnumBaseType, type MaybePromise, type Values } from '@augment-vir/
|
|
|
6
6
|
* @category Package : @augment-vir/common
|
|
7
7
|
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
8
8
|
*/
|
|
9
|
-
export type EnumMap<Enum extends EnumBaseType, Value> =
|
|
10
|
-
export declare function mapEnumToObject<const Enum extends EnumBaseType, const Value>(enumInput: Enum, callback: (enumValue:
|
|
11
|
-
export declare function mapEnumToObject<const Enum extends EnumBaseType, const Value>(enumInput: Enum, callback: (enumValue:
|
|
9
|
+
export type EnumMap<Enum extends EnumBaseType, Value> = CompleteValues<Enum> extends PropertyKey ? Record<CompleteValues<Enum>, Value> : 'ERROR: invalid enum';
|
|
10
|
+
export declare function mapEnumToObject<const Enum extends EnumBaseType, const Value>(enumInput: Enum, callback: (enumValue: CompleteValues<Enum>) => Promise<Value>): Promise<EnumMap<Enum, Value>>;
|
|
11
|
+
export declare function mapEnumToObject<const Enum extends EnumBaseType, const Value>(enumInput: Enum, callback: (enumValue: CompleteValues<Enum>, wholeEnum: Enum) => Value): Value extends Promise<any> ? Promise<any> extends Value ? Promise<EnumMap<Enum, Awaited<Value>>> : MaybePromise<EnumMap<Enum, Awaited<Value>>> : EnumMap<Enum, Value>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/common",
|
|
3
|
-
"version": "31.68.
|
|
3
|
+
"version": "31.68.3",
|
|
4
4
|
"description": "A collection of augments, helpers types, functions, and classes for any JavaScript environment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"augment",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"test:web": "virmator --no-deps test web"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@augment-vir/assert": "^31.68.
|
|
44
|
-
"@augment-vir/core": "^31.68.
|
|
43
|
+
"@augment-vir/assert": "^31.68.3",
|
|
44
|
+
"@augment-vir/core": "^31.68.3",
|
|
45
45
|
"@date-vir/duration": "^8.2.0",
|
|
46
46
|
"ansi-styles": "^6.2.3",
|
|
47
47
|
"deepcopy-esm": "^2.1.1",
|