@augment-vir/common 31.27.0 → 31.28.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.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type AnyObject } from '@augment-vir/core';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the type of a nested property within `Parent` by recursively accessing each key in `Keys`.
|
|
4
|
+
*
|
|
5
|
+
* @category Object
|
|
6
|
+
* @category Package : @augment-vir/common
|
|
7
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
8
|
+
*/
|
|
9
|
+
export type DeepValue<Parent extends AnyObject, Keys extends ReadonlyArray<PropertyKey>> = Keys extends Readonly<[infer First, ...infer Rest]> ? First extends keyof Parent ? Rest extends ReadonlyArray<PropertyKey> ? DeepValue<Parent[First], Rest> : undefined : undefined : Parent;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the value of a nested property within `Parent` by recursively accessing each key in `Keys`.
|
|
12
|
+
*
|
|
13
|
+
* @category Object
|
|
14
|
+
* @category Package : @augment-vir/common
|
|
15
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
16
|
+
*/
|
|
17
|
+
export declare function getDeepValue<const Parent extends AnyObject, const Keys extends ReadonlyArray<PropertyKey>>(parent: Parent, keys: Readonly<Keys>): DeepValue<Parent, Keys>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the value of a nested property within `Parent` by recursively accessing each key in `Keys`.
|
|
4
|
+
*
|
|
5
|
+
* @category Object
|
|
6
|
+
* @category Package : @augment-vir/common
|
|
7
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
8
|
+
*/
|
|
9
|
+
export function getDeepValue(parent, keys) {
|
|
10
|
+
if (!keys.length) {
|
|
11
|
+
return parent;
|
|
12
|
+
}
|
|
13
|
+
const innerParent = parent;
|
|
14
|
+
const currentKey = keys[0];
|
|
15
|
+
if (currentKey != undefined && check.hasKey(innerParent, currentKey)) {
|
|
16
|
+
return getDeepValue(innerParent[currentKey], keys.slice(1));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export * from './augments/number/scientific.js';
|
|
|
39
39
|
export * from './augments/number/truncate-number.js';
|
|
40
40
|
export * from './augments/number/wrap-number.js';
|
|
41
41
|
export * from './augments/object/deep-copy.js';
|
|
42
|
+
export * from './augments/object/deep-value.js';
|
|
42
43
|
export * from './augments/object/diff.js';
|
|
43
44
|
export * from './augments/object/empty.js';
|
|
44
45
|
export * from './augments/object/get-or-set.js';
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export * from './augments/number/scientific.js';
|
|
|
39
39
|
export * from './augments/number/truncate-number.js';
|
|
40
40
|
export * from './augments/number/wrap-number.js';
|
|
41
41
|
export * from './augments/object/deep-copy.js';
|
|
42
|
+
export * from './augments/object/deep-value.js';
|
|
42
43
|
export * from './augments/object/diff.js';
|
|
43
44
|
export * from './augments/object/empty.js';
|
|
44
45
|
export * from './augments/object/get-or-set.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/common",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.28.0",
|
|
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.
|
|
44
|
-
"@augment-vir/core": "^31.
|
|
43
|
+
"@augment-vir/assert": "^31.28.0",
|
|
44
|
+
"@augment-vir/core": "^31.28.0",
|
|
45
45
|
"@date-vir/duration": "^7.3.2",
|
|
46
46
|
"ansi-styles": "^6.2.1",
|
|
47
47
|
"deepcopy-esm": "^2.1.1",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@web/test-runner-playwright": "^0.11.1",
|
|
57
57
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
58
58
|
"concurrently": "^9.2.0",
|
|
59
|
-
"execute-in-browser": "^1.0.
|
|
59
|
+
"execute-in-browser": "^1.0.8",
|
|
60
60
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
61
61
|
"typescript": "^5.8.3"
|
|
62
62
|
},
|