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

Function _getPathRecursive

commonjs/helpers.js:99–115  ·  view source on GitHub ↗
(root, obj)

Source from the content-addressed store, hash-verified

97}
98exports.unescapePathComponent = unescapePathComponent;
99function _getPathRecursive(root, obj) {
100 var found;
101 for (var key in root) {
102 if (hasOwnProperty(root, key)) {
103 if (root[key] === obj) {
104 return escapePathComponent(key) + '/';
105 }
106 else if (typeof root[key] === 'object') {
107 found = _getPathRecursive(root[key], obj);
108 if (found != '') {
109 return escapePathComponent(key) + '/' + found;
110 }
111 }
112 }
113 }
114 return '';
115}
116exports._getPathRecursive = _getPathRecursive;
117function getPath(root, obj) {
118 if (root === obj) {

Callers 1

getPathFunction · 0.70

Calls 2

hasOwnPropertyFunction · 0.70
escapePathComponentFunction · 0.70

Tested by

no test coverage detected