MCPcopy Create free account
hub / github.com/Starcounter-Jack/JSON-Patch / _getPathRecursive

Function _getPathRecursive

src/helpers.ts:79–95  ·  view source on GitHub ↗
(root: Object, obj: Object)

Source from the content-addressed store, hash-verified

77}
78
79export function _getPathRecursive(root: Object, obj: Object): string {
80 let found;
81 for (let key in root) {
82 if (hasOwnProperty(root, key)) {
83 if (root[key] === obj) {
84 return escapePathComponent(key) + '/';
85 }
86 else if (typeof root[key] === 'object') {
87 found = _getPathRecursive(root[key], obj);
88 if (found != '') {
89 return escapePathComponent(key) + '/' + found;
90 }
91 }
92 }
93 }
94 return '';
95}
96
97export function getPath(root: Object, obj: Object): string {
98 if (root === obj) {

Callers 1

getPathFunction · 0.70

Calls 2

hasOwnPropertyFunction · 0.70
escapePathComponentFunction · 0.70

Tested by

no test coverage detected