lib/resolve-external.js
function crawl (obj, path, $refs, options) {
  var promises = [];

  if (obj && typeof obj === "object") {
    if ($Ref.isExternal$Ref(obj)) {
      promises.push(resolve$Ref(obj, path, $refs, options));
    }
    else {
      Object.keys(obj).forEach(function (key) {
        var keyPath = Pointer.join(path, key);
        var value = obj[key];

        if ($Ref.isExternal$Ref(value)) {
          promises.push(resolve$Ref(value, keyPath, $refs, options));
        }
        else {
          promises = promises.concat(crawl(value, keyPath, $refs, options));
        }
      });
    }
  }

  return promises;
}
function crawl (obj, path, $refs, options) {
  var promises = [];

  if (obj && typeof obj === "object") {
    if ($Ref.isExternal$Ref(obj)) {
      promises.push(resolve$Ref(obj, path, $refs, options));
    }
    else {
      Object.keys(obj).forEach(function (key) {
        var keyPath = Pointer.join(path, key);
        var value = obj[key];

        if ($Ref.isExternal$Ref(value)) {
          promises.push(resolve$Ref(value, keyPath, $refs, options));
        }
        else {
          promises = promises.concat(crawl(value, keyPath, $refs, options));
        }
      });
    }
  }

  return promises;
}
function crawl ( obj , path , $refs , options ) { var promises = [ ] ; if ( obj && typeof obj === "object" ) { if ( $Ref . isExternal$Ref ( obj ) ) { promises . push ( resolve$Ref ( obj , path , $refs , options ) ) ; } else { Object . keys ( obj ) . forEach ( function ( key ) { var keyPath = Pointer . join ( path , key ) ; var value = obj [ key ] ; if ( $Ref . isExternal$Ref ( value ) ) { promises . push ( resolve$Ref ( value , keyPath , $refs , options ) ) ; } else { promises = promises . concat ( crawl ( value , keyPath , $refs , options ) ) ; } } ) ; } } return promises ; }
Recursively crawls the given value, and resolves any external JSON references.

@param {*} obj - The value to crawl. If it's not an object or array, it will be ignored.
@param {string} path - The full path of `obj`, possibly with a JSON Pointer in the hash
@param {$Refs} $refs
@param {$RefParserOptions} options

@returns {Promise[]}
Returns an array of promises. There will be one promise for each JSON reference in `obj`.
If `obj` does not contain any JSON references, then the array will be empty.
If any of the JSON references point to files that contain additional JSON references,
then the corresponding promise will internally reference an array of promises.
Recursively crawls the given value and resolves any external JSON references .