@augment-vir/common
Advanced tools
Comparing version 28.1.0 to 28.1.1
@@ -7,2 +7,3 @@ "use strict"; | ||
const typed_has_property_1 = require("./typed-has-property"); | ||
/** This mutates the {@link originalObject} input. */ | ||
function setValueWithNestedKeys(originalObject, nestedKeys, value) { | ||
@@ -9,0 +10,0 @@ /** |
@@ -25,3 +25,3 @@ "use strict"; | ||
timeout: { | ||
milliseconds: 10000, | ||
milliseconds: 10_000, | ||
}, | ||
@@ -28,0 +28,0 @@ }; |
@@ -58,2 +58,3 @@ "use strict"; | ||
__exportStar(require("./augments/type"), exports); | ||
__exportStar(require("./augments/type-recursion"), exports); | ||
__exportStar(require("./augments/wrap-in-try"), exports); |
import { isRunTimeType } from 'run-time-assertions'; | ||
import { isObject } from './object'; | ||
import { typedHasProperty } from './typed-has-property'; | ||
/** This mutates the {@link originalObject} input. */ | ||
export function setValueWithNestedKeys(originalObject, nestedKeys, value) { | ||
@@ -5,0 +6,0 @@ /** |
@@ -20,3 +20,3 @@ import { ensureErrorAndPrependMessage } from '../error'; | ||
timeout: { | ||
milliseconds: 10000, | ||
milliseconds: 10_000, | ||
}, | ||
@@ -23,0 +23,0 @@ }; |
@@ -42,2 +42,3 @@ export * from './augments/ansi'; | ||
export * from './augments/type'; | ||
export * from './augments/type-recursion'; | ||
export * from './augments/wrap-in-try'; |
import { ArrayElement } from '../type'; | ||
import { TsRecurse, TsRecursionStart, TsRecursionTracker, TsTooMuchRecursion } from '../type-recursion'; | ||
import { PropertyValueType } from './object'; | ||
import { UnionToIntersection } from './old-union-to-intersection'; | ||
export type NestedSequentialKeys<ObjectGeneric extends object> = NonNullable<ObjectGeneric> extends ReadonlyArray<any> ? Extract<NonNullable<ObjectGeneric>[number], object> extends never ? [number] : NestedSequentialKeys<Extract<NonNullable<ObjectGeneric>[number], object>> : PropertyValueType<{ | ||
export type NestedSequentialKeys<ObjectGeneric extends object, Depth extends TsRecursionTracker = TsRecursionStart> = Depth extends TsTooMuchRecursion ? ['Error: recursive object depth is too deep.'] : NonNullable<ObjectGeneric> extends ReadonlyArray<any> ? Extract<NonNullable<ObjectGeneric>[number], object> extends never ? [number] : NestedSequentialKeys<Extract<NonNullable<ObjectGeneric>[number], object>, TsRecurse<Depth>> : PropertyValueType<{ | ||
[Prop in keyof ObjectGeneric]: NonNullable<ObjectGeneric[Prop]> extends object ? Readonly<[ | ||
Prop, | ||
...(NestedSequentialKeys<NonNullable<ObjectGeneric[Prop]>> | []) | ||
...(NestedSequentialKeys<NonNullable<ObjectGeneric[Prop]>, TsRecurse<Depth>> | []) | ||
]> : Readonly<[Prop]>; | ||
}>; | ||
export type NestedKeys<ObjectGeneric extends object> = ObjectGeneric extends ReadonlyArray<any> ? NestedKeys<ArrayElement<ObjectGeneric>> : UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>> extends object ? [ | ||
export type NestedKeys<ObjectGeneric extends object, Depth extends TsRecursionTracker = TsRecursionStart> = Depth extends TsTooMuchRecursion ? ['Error: recursive object depth is too deep.'] : ObjectGeneric extends ReadonlyArray<any> ? NestedKeys<ArrayElement<ObjectGeneric>, TsRecurse<Depth>> : UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>> extends object ? [ | ||
keyof ObjectGeneric, | ||
...(NestedKeys<UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>>> | []) | ||
...(NestedKeys<UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>>, TsRecurse<Depth>> | []) | ||
] : [keyof ObjectGeneric]; | ||
export type NestedValue<ObjectGeneric extends object, NestedKeysGeneric extends NestedSequentialKeys<ObjectGeneric>> = ObjectGeneric extends ReadonlyArray<any> ? NestedValue<Extract<ObjectGeneric[number], object>, NestedKeysGeneric>[] : NestedKeysGeneric extends readonly [infer FirstEntry, ...infer FollowingEntries] ? FirstEntry extends keyof ObjectGeneric ? FollowingEntries extends never[] ? ObjectGeneric[FirstEntry] : ObjectGeneric[FirstEntry] extends object ? FollowingEntries extends NestedSequentialKeys<ObjectGeneric[FirstEntry]> ? NestedValue<ObjectGeneric[FirstEntry], FollowingEntries> : never : never : never : never; | ||
export declare function setValueWithNestedKeys<const ObjectGeneric extends object, const KeysGeneric extends NestedSequentialKeys<ObjectGeneric>>(originalObject: ObjectGeneric, nestedKeys: KeysGeneric, value: NestedValue<ObjectGeneric, KeysGeneric>): void; | ||
/** This mutates the {@link originalObject} input. */ | ||
export declare function setValueWithNestedKeys<const ObjectGeneric extends object, const KeysGeneric extends NestedSequentialKeys<ObjectGeneric>>(originalObject: ObjectGeneric, nestedKeys: Readonly<KeysGeneric>, value: Readonly<NestedValue<ObjectGeneric, KeysGeneric>>): void; | ||
export declare function getValueFromNestedKeys<const ObjectGeneric extends object, const KeysGeneric extends NestedSequentialKeys<ObjectGeneric>>(originalObject: ObjectGeneric, nestedKeys: KeysGeneric): NestedValue<ObjectGeneric, KeysGeneric>; |
import { OptionalKeysOf, RequiredKeysOf } from 'type-fest'; | ||
import { AnyFunction } from '../function'; | ||
import { ArrayElement } from '../type'; | ||
import { TsRecurse, TsRecursionStart, TsRecursionTracker } from '../type-recursion'; | ||
import { AnyObject } from './any-object'; | ||
import { NestedKeys } from './nested-keys'; | ||
export type InnerPickDeep<OriginalObject extends AnyObject, DeepKeys extends any[]> = DeepKeys extends [infer CurrentLevelPick, ...infer RemainingKeys] ? Extract<CurrentLevelPick, keyof OriginalObject> extends never ? OriginalObject : { | ||
[CurrentProp in Extract<CurrentLevelPick, RequiredKeysOf<OriginalObject>>]: InnerPickDeepValue<OriginalObject, CurrentProp, RemainingKeys>; | ||
export type InnerPickDeep<OriginalObject extends AnyObject, DeepKeys extends any[], Depth extends TsRecursionTracker> = DeepKeys extends [infer CurrentLevelPick, ...infer RemainingKeys] ? Extract<CurrentLevelPick, keyof OriginalObject> extends never ? OriginalObject : { | ||
[CurrentProp in Extract<CurrentLevelPick, RequiredKeysOf<OriginalObject>>]: InnerPickDeepValue<OriginalObject, CurrentProp, RemainingKeys, Depth>; | ||
} & { | ||
[CurrentProp in Extract<CurrentLevelPick, OptionalKeysOf<OriginalObject>>]?: InnerPickDeepValue<OriginalObject, CurrentProp, RemainingKeys>; | ||
[CurrentProp in Extract<CurrentLevelPick, OptionalKeysOf<OriginalObject>>]?: InnerPickDeepValue<OriginalObject, CurrentProp, RemainingKeys, Depth>; | ||
} : DeepKeys extends [] ? OriginalObject : DeepKeys extends [infer CurrentLevelPick] ? CurrentLevelPick extends keyof OriginalObject ? Pick<OriginalObject, CurrentLevelPick> : never : never; | ||
type InnerPickDeepValue<OriginalObject, CurrentProp extends keyof OriginalObject, RemainingKeys extends any[]> = AnyFunction extends Extract<OriginalObject[CurrentProp], AnyFunction> ? OriginalObject[CurrentProp] | Exclude<OriginalObject[CurrentProp], AnyFunction> : Array<any> extends Extract<OriginalObject[CurrentProp], Array<any>> ? Array<InnerPickDeep<ArrayElement<Extract<OriginalObject[CurrentProp], Array<any>>>, RemainingKeys>> | Exclude<OriginalObject[CurrentProp], Array<any>> : ReadonlyArray<any> extends Extract<OriginalObject[CurrentProp], ReadonlyArray<any>> ? ReadonlyArray<InnerPickDeep<ArrayElement<Extract<OriginalObject[CurrentProp], ReadonlyArray<any>>>, RemainingKeys>> | Exclude<OriginalObject[CurrentProp], ReadonlyArray<any>> : Extract<OriginalObject[CurrentProp], Record<any, any>> extends never ? OriginalObject[CurrentProp] : InnerPickDeep<Extract<OriginalObject[CurrentProp], Record<any, any>>, RemainingKeys> | Exclude<OriginalObject[CurrentProp], Record<any, any>>; | ||
type InnerPickDeepValue<OriginalObject, CurrentProp extends keyof OriginalObject, RemainingKeys extends any[], Depth extends TsRecursionTracker> = AnyFunction extends Extract<OriginalObject[CurrentProp], AnyFunction> ? OriginalObject[CurrentProp] | Exclude<OriginalObject[CurrentProp], AnyFunction> : Array<any> extends Extract<OriginalObject[CurrentProp], Array<any>> ? Array<InnerPickDeep<ArrayElement<Extract<OriginalObject[CurrentProp], Array<any>>>, RemainingKeys, TsRecurse<Depth>>> | Exclude<OriginalObject[CurrentProp], Array<any>> : ReadonlyArray<any> extends Extract<OriginalObject[CurrentProp], ReadonlyArray<any>> ? ReadonlyArray<InnerPickDeep<ArrayElement<Extract<OriginalObject[CurrentProp], ReadonlyArray<any>>>, RemainingKeys, TsRecurse<Depth>>> | Exclude<OriginalObject[CurrentProp], ReadonlyArray<any>> : Extract<OriginalObject[CurrentProp], Record<any, any>> extends never ? OriginalObject[CurrentProp] : InnerPickDeep<Extract<OriginalObject[CurrentProp], Record<any, any>>, RemainingKeys, TsRecurse<Depth>> | Exclude<OriginalObject[CurrentProp], Record<any, any>>; | ||
/** | ||
@@ -16,5 +17,5 @@ * Pick nested keys with more strict type parameter requirements. However, these stricter type | ||
*/ | ||
export type PickDeepStrict<OriginalObject extends object, DeepKeys extends NestedKeys<OriginalObject>> = InnerPickDeep<OriginalObject, DeepKeys>; | ||
export type PickDeepStrict<OriginalObject extends object, DeepKeys extends NestedKeys<OriginalObject>> = InnerPickDeep<OriginalObject, DeepKeys, TsRecursionStart>; | ||
/** Pick nested keys. */ | ||
export type PickDeep<OriginalObject extends object, DeepKeys extends PropertyKey[]> = InnerPickDeep<OriginalObject, DeepKeys>; | ||
export type PickDeep<OriginalObject extends object, DeepKeys extends PropertyKey[]> = InnerPickDeep<OriginalObject, DeepKeys, TsRecursionStart>; | ||
export {}; |
@@ -42,2 +42,3 @@ export * from './augments/ansi'; | ||
export * from './augments/type'; | ||
export * from './augments/type-recursion'; | ||
export * from './augments/wrap-in-try'; |
{ | ||
"name": "@augment-vir/common", | ||
"version": "28.1.0", | ||
"version": "28.1.1", | ||
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common", | ||
@@ -27,8 +27,8 @@ "bugs": { | ||
"dependencies": { | ||
"browser-or-node": "^2.1.1", | ||
"run-time-assertions": "^1.0.0", | ||
"type-fest": "^4.12.0" | ||
"browser-or-node": "^3.0.0", | ||
"run-time-assertions": "^1.5.1", | ||
"type-fest": "^4.20.1" | ||
}, | ||
"devDependencies": { | ||
"typescript": "5.3.3" | ||
"typescript": "5.4.5" | ||
}, | ||
@@ -35,0 +35,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170026
134
4283
- Removedbrowser-or-node@2.1.1(transitive)
Updatedbrowser-or-node@^3.0.0
Updatedrun-time-assertions@^1.5.1
Updatedtype-fest@^4.20.1