MCPcopy Index your code
hub / github.com/Starcounter-Jack/JSON-Patch / _getPathRecursive

Function _getPathRecursive

module/helpers.mjs:92–108  ·  view source on GitHub ↗
(root, obj)

Source from the content-addressed store, hash-verified

90 return path.replace(/~1/g, '/').replace(/~0/g, '~');
91}
92export function _getPathRecursive(root, obj) {
93 var found;
94 for (var key in root) {
95 if (hasOwnProperty(root, key)) {
96 if (root[key] === obj) {
97 return escapePathComponent(key) + '/';
98 }
99 else if (typeof root[key] === 'object') {
100 found = _getPathRecursive(root[key], obj);
101 if (found != '') {
102 return escapePathComponent(key) + '/' + found;
103 }
104 }
105 }
106 }
107 return '';
108}
109export function getPath(root, obj) {
110 if (root === obj) {
111 return '/';

Callers 1

getPathFunction · 0.70

Calls 2

hasOwnPropertyFunction · 0.70
escapePathComponentFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…