@augment-vir/common 29.1.1 → 29.1.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.
|
@@ -7,7 +7,7 @@ const tuple_1 = require("../tuple");
|
|
|
7
7
|
const filter_object_1 = require("./filter-object");
|
|
8
8
|
const map_object_1 = require("./map-object");
|
|
9
9
|
function shouldPreserve(input) {
|
|
10
|
-
return (0, run_time_assertions_1.isPrimitive)(input) || input instanceof RegExp;
|
|
10
|
+
return (0, run_time_assertions_1.isPrimitive)(input) || input instanceof RegExp || input instanceof Promise;
|
|
11
11
|
}
|
|
12
12
|
function selectFrom(originalObject, selectionSet) {
|
|
13
13
|
if (Array.isArray(originalObject)) {
|
|
@@ -28,7 +28,7 @@ function selectFrom(originalObject, selectionSet) {
|
|
|
28
28
|
}
|
|
29
29
|
}), keysToRemove);
|
|
30
30
|
}
|
|
31
|
-
function selectCollapsedFrom(originalObject, selectionSet
|
|
31
|
+
function selectCollapsedFrom(originalObject, selectionSet) {
|
|
32
32
|
const selected = selectFrom(originalObject, selectionSet);
|
|
33
33
|
return collapseObject(selected);
|
|
34
34
|
}
|
|
@@ -3,7 +3,7 @@ import { isLengthAtLeast } from '../tuple';
|
|
|
3
3
|
import { omitObjectKeys } from './filter-object';
|
|
4
4
|
import { mapObjectValues } from './map-object';
|
|
5
5
|
function shouldPreserve(input) {
|
|
6
|
-
return isPrimitive(input) || input instanceof RegExp;
|
|
6
|
+
return isPrimitive(input) || input instanceof RegExp || input instanceof Promise;
|
|
7
7
|
}
|
|
8
8
|
export function selectFrom(originalObject, selectionSet) {
|
|
9
9
|
if (Array.isArray(originalObject)) {
|
|
@@ -24,7 +24,7 @@ export function selectFrom(originalObject, selectionSet) {
|
|
|
24
24
|
}
|
|
25
25
|
}), keysToRemove);
|
|
26
26
|
}
|
|
27
|
-
export function selectCollapsedFrom(originalObject, selectionSet
|
|
27
|
+
export function selectCollapsedFrom(originalObject, selectionSet) {
|
|
28
28
|
const selected = selectFrom(originalObject, selectionSet);
|
|
29
29
|
return collapseObject(selected);
|
|
30
30
|
}
|
|
@@ -5,7 +5,7 @@ import { AnyObject } from './any-object';
|
|
|
5
5
|
import { KeyCount } from './key-count';
|
|
6
6
|
import { PropertyValueType } from './object';
|
|
7
7
|
/** All types that won't be recursed into when defining a {@link SelectionSet}. */
|
|
8
|
-
export type SelectionTypesToPreserve = Primitive | RegExp
|
|
8
|
+
export type SelectionTypesToPreserve = Primitive | RegExp | Promise<any>;
|
|
9
9
|
/** A generic selection set without specific keys. */
|
|
10
10
|
export type GenericSelectionSet = {
|
|
11
11
|
[Key in PropertyKey]: boolean | GenericSelectionSet | unknown;
|
|
@@ -18,10 +18,10 @@ export type PickSelection<Full extends Readonly<AnyObject>, Selection extends Ge
|
|
|
18
18
|
* Collapses a selected value to the first part of the selection that contains more than 1 key or
|
|
19
19
|
* that is not an object.
|
|
20
20
|
*/
|
|
21
|
-
export type
|
|
21
|
+
export type PickCollapsedSelection<Full extends Readonly<AnyObject>, Selection extends GenericSelectionSet, Depth extends TsRecursionTracker = TsRecursionStart> = Depth extends TsTooMuchRecursion ? 'Error: recursive object depth is too deep.' : KeyCount<PickSelection<Full, Selection, Depth>> extends 1 ? Selection[keyof PickSelection<Full, Selection, Depth>] extends GenericSelectionSet ? PickCollapsedSelection<Full[keyof PickSelection<Full, Selection, Depth>], Selection[keyof PickSelection<Full, Selection, Depth>], TsRecurse<Depth>> : PropertyValueType<PickSelection<Full, Selection, Depth>> : PickSelection<Full, Selection, Depth>;
|
|
22
22
|
/** Defines a selection set for the given object. */
|
|
23
23
|
export type SelectionSet<Full extends Readonly<AnyObject>, Depth extends TsRecursionTracker = TsRecursionStart> = IsAny<Full> extends true ? any : Depth extends TsTooMuchRecursion ? ['Error: recursive object depth is too deep.'] : Full extends ReadonlyArray<infer FullChild extends AnyObject> ? SelectionSet<FullChild, TsRecurse<Depth>> : Partial<{
|
|
24
24
|
[Key in keyof Full]: IsNever<Exclude<Full[Key], SelectionTypesToPreserve>> extends true ? boolean : boolean | UnionToIntersection<SelectionSet<Full[Key], TsRecurse<Depth>>>;
|
|
25
25
|
}>;
|
|
26
26
|
export declare function selectFrom<Full extends AnyObject, const Selection extends SelectionSet<NoInfer<Full>>>(originalObject: Readonly<Full>, selectionSet: Readonly<Selection>): PickSelection<Full, Selection>;
|
|
27
|
-
export declare function selectCollapsedFrom<Full extends AnyObject, const Selection extends SelectionSet<NoInfer<Full
|
|
27
|
+
export declare function selectCollapsedFrom<Full extends AnyObject, const Selection extends SelectionSet<NoInfer<Full>>>(originalObject: Readonly<Full>, selectionSet: Readonly<Selection>): PickCollapsedSelection<Full, Selection>;
|