(object, path)
| 1293 | // Path is a list of fields to search into. |
| 1294 | // Returns a list of pointers in REST format. |
| 1295 | function findPointers(object, path) { |
| 1296 | if (Array.isArray(object)) { |
| 1297 | return object.map(x => findPointers(x, path)).flat(); |
| 1298 | } |
| 1299 | |
| 1300 | if (typeof object !== 'object' || !object) { |
| 1301 | return []; |
| 1302 | } |
| 1303 | |
| 1304 | if (path.length == 0) { |
| 1305 | if (object === null || object.__type == 'Pointer') { |
| 1306 | return [object]; |
| 1307 | } |
| 1308 | return []; |
| 1309 | } |
| 1310 | |
| 1311 | var subobject = object[path[0]]; |
| 1312 | if (!subobject) { |
| 1313 | return []; |
| 1314 | } |
| 1315 | return findPointers(subobject, path.slice(1)); |
| 1316 | } |
| 1317 | |
| 1318 | // Object may be a list of REST-format objects to replace pointers |
| 1319 | // in, or it may be a single object. |
no outgoing calls
no test coverage detected
searching dependent graphs…