lib/bundle.js
function crawl (parent, key, path, pathFromRoot, indirections, inventory, $refs, options) {
  var obj = key === null ? parent : parent[key];

  if (obj && typeof obj === "object") {
    if ($Ref.isAllowed$Ref(obj)) {
      inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options);
    }
    else {
      // Crawl the object in a specific order that's optimized for bundling.
      // This is important because it determines how `pathFromRoot` gets built,
      // which later determines which keys get dereferenced and which ones get remapped
      var keys = Object.keys(obj)
        .sort(function (a, b) {
          // Most people will expect references to be bundled into the the "definitions" property,
          // so we always crawl that property first, if it exists.
          if (a === "definitions") {
            return -1;
          }
          else if (b === "definitions") {
            return 1;
          }
          else {
            // Otherwise, crawl the keys based on their length.
            // This produces the shortest possible bundled references
            return a.length - b.length;
          }
        });

      keys.forEach(function (key) {
        var keyPath = Pointer.join(path, key);
        var keyPathFromRoot = Pointer.join(pathFromRoot, key);
        var value = obj[key];

        if ($Ref.isAllowed$Ref(value)) {
          inventory$Ref(obj, key, path, keyPathFromRoot, indirections, inventory, $refs, options);
        }
        else {
          crawl(obj, key, keyPath, keyPathFromRoot, indirections, inventory, $refs, options);
        }
      });
    }
  }
}
function crawl (parent, key, path, pathFromRoot, indirections, inventory, $refs, options) {
  var obj = key === null ? parent : parent[key];

  if (obj && typeof obj === "object") {
    if ($Ref.isAllowed$Ref(obj)) {
      inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options);
    }
    else {
      // Crawl the object in a specific order that's optimized for bundling.
      // This is important because it determines how `pathFromRoot` gets built,
      // which later determines which keys get dereferenced and which ones get remapped
      var keys = Object.keys(obj)
        .sort(function (a, b) {
          // Most people will expect references to be bundled into the the "definitions" property,
          // so we always crawl that property first, if it exists.
          if (a === "definitions") {
            return -1;
          }
          else if (b === "definitions") {
            return 1;
          }
          else {
            // Otherwise, crawl the keys based on their length.
            // This produces the shortest possible bundled references
            return a.length - b.length;
          }
        });

      keys.forEach(function (key) {
        var keyPath = Pointer.join(path, key);
        var keyPathFromRoot = Pointer.join(pathFromRoot, key);
        var value = obj[key];

        if ($Ref.isAllowed$Ref(value)) {
          inventory$Ref(obj, key, path, keyPathFromRoot, indirections, inventory, $refs, options);
        }
        else {
          crawl(obj, key, keyPath, keyPathFromRoot, indirections, inventory, $refs, options);
        }
      });
    }
  }
}
function crawl ( parent , key , path , pathFromRoot , indirections , inventory , $refs , options ) { var obj = key === null ? parent : parent [ key ] ; if ( obj && typeof obj === "object" ) { if ( $Ref . isAllowed$Ref ( obj ) ) { inventory$Ref ( parent , key , path , pathFromRoot , indirections , inventory , $refs , options ) ; } else { // Crawl the object in a specific order that's optimized for bundling. // This is important because it determines how `pathFromRoot` gets built, // which later determines which keys get dereferenced and which ones get remapped var keys = Object . keys ( obj ) . sort ( function ( a , b ) { // Most people will expect references to be bundled into the the "definitions" property, // so we always crawl that property first, if it exists. if ( a === "definitions" ) { return - 1 ; } else if ( b === "definitions" ) { return 1 ; } else { // Otherwise, crawl the keys based on their length. // This produces the shortest possible bundled references return a . length - b . length ; } } ) ; keys . forEach ( function ( key ) { var keyPath = Pointer . join ( path , key ) ; var keyPathFromRoot = Pointer . join ( pathFromRoot , key ) ; var value = obj [ key ] ; if ( $Ref . isAllowed$Ref ( value ) ) { inventory$Ref ( obj , key , path , keyPathFromRoot , indirections , inventory , $refs , options ) ; } else { crawl ( obj , key , keyPath , keyPathFromRoot , indirections , inventory , $refs , options ) ; } } ) ; } } }
Recursively crawls the given value, and inventories all JSON references.

@param {object} parent - The object containing the value to crawl. If the value is not an object or array, it will be ignored.
@param {string} key - The property key of `parent` to be crawled
@param {string} path - The full path of the property being crawled, possibly with a JSON Pointer in the hash
@param {string} pathFromRoot - The path of the property being crawled, from the schema root
@param {object[]} inventory - An array of already-inventoried $ref pointers
@param {$Refs} $refs
@param {$RefParserOptions} options
Recursively crawls the given value and inventories all JSON references .