src/parse-mockdb.js
function includePaths(object, pathsRemaining) {
  debugPrint('INCLUDE', { object, pathsRemaining });
  const path = pathsRemaining.shift();
  const target = object && object[path];

  if (target) {
    if (Array.isArray(target)) {
      object[path] = target.map(pointer => {
        const fetched = fetchObjectByPointer(pointer);
        includePaths(fetched, _.cloneDeep(pathsRemaining));
        return fetched;
      });
    } else {
      if (object[path].__type === 'Pointer') {
        object[path] = fetchObjectByPointer(target);
      }
      includePaths(object[path], pathsRemaining);
    }
  }

  return object;
}
function includePaths(object, pathsRemaining) {
  debugPrint('INCLUDE', { object, pathsRemaining });
  const path = pathsRemaining.shift();
  const target = object && object[path];

  if (target) {
    if (Array.isArray(target)) {
      object[path] = target.map(pointer => {
        const fetched = fetchObjectByPointer(pointer);
        includePaths(fetched, _.cloneDeep(pathsRemaining));
        return fetched;
      });
    } else {
      if (object[path].__type === 'Pointer') {
        object[path] = fetchObjectByPointer(target);
      }
      includePaths(object[path], pathsRemaining);
    }
  }

  return object;
}
function includePaths ( object , pathsRemaining ) { debugPrint ( 'INCLUDE' , { object , pathsRemaining } ) ; const path = pathsRemaining . shift ( ) ; const target = object && object [ path ] ; if ( target ) { if ( Array . isArray ( target ) ) { object [ path ] = target . map ( pointer => { const fetched = fetchObjectByPointer ( pointer ) ; includePaths ( fetched , _ . cloneDeep ( pathsRemaining ) ) ; return fetched ; } ) ; } else { if ( object [ path ] . __type === 'Pointer' ) { object [ path ] = fetchObjectByPointer ( target ) ; } includePaths ( object [ path ] , pathsRemaining ) ; } } return object ; }
Recursive function that traverses an include path and replaces pointers
with fully fetched objects
Recursive function that traverses an include path and replaces pointers with fully fetched objects