We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fc35500 commit 09edbafCopy full SHA for 09edbaf
1 file changed
src/utils/objects.util.ts
@@ -0,0 +1,19 @@
1
+/**
2
+ * Find an object inside another object by a given path
3
+ * @param $ref Path to find EX: '#/level1/level2/level3'
4
+ * @param fullObject Full instance of the object
5
+ */
6
+export function findInObject($ref: string, fullObject: any): any {
7
+ const path = $ref.split('/');
8
+
9
+ let child = path.shift(); // Skip the root (#)
10
+ let currentPath = fullObject;
11
+ while ((child = path.shift())) {
12
+ if (!currentPath[child]) {
13
+ return null;
14
+ }
15
+ currentPath = currentPath[child];
16
17
18
+ return currentPath;
19
+}
0 commit comments