(root, obj)
| 90 | return path.replace(/~1/g, '/').replace(/~0/g, '~'); |
| 91 | } |
| 92 | export 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 | } |
| 109 | export function getPath(root, obj) { |
| 110 | if (root === obj) { |
| 111 | return '/'; |
no test coverage detected
searching dependent graphs…