npm-crawl.js
function(){
		var pkg = utils.extend({}, this.orig);

		var isFlat = this.context.isFlatFileStructure;
		var fileUrl = this.pkg.fileUrl;
		var context = this.context;

		if(isFlat && !pkg.__crawledNestedPosition) {
			pkg.__crawledNestedPosition = true;
			pkg.nextFileUrl = pkg.nestedFileUrl;
		}
		else {
			// make sure we aren't loading something we've already loaded
			var parentAddress = utils.path.parentNodeModuleAddress(fileUrl);
			if(!parentAddress) {
				throw new Error('Did not find ' + pkg.origFileUrl);
			}
			var nodeModuleAddress = parentAddress + "/" + pkg.name +
				"/package.json";

			pkg.nextFileUrl = nodeModuleAddress;
		}

		return pkg;
	}
function(){
		var pkg = utils.extend({}, this.orig);

		var isFlat = this.context.isFlatFileStructure;
		var fileUrl = this.pkg.fileUrl;
		var context = this.context;

		if(isFlat && !pkg.__crawledNestedPosition) {
			pkg.__crawledNestedPosition = true;
			pkg.nextFileUrl = pkg.nestedFileUrl;
		}
		else {
			// make sure we aren't loading something we've already loaded
			var parentAddress = utils.path.parentNodeModuleAddress(fileUrl);
			if(!parentAddress) {
				throw new Error('Did not find ' + pkg.origFileUrl);
			}
			var nodeModuleAddress = parentAddress + "/" + pkg.name +
				"/package.json";

			pkg.nextFileUrl = nodeModuleAddress;
		}

		return pkg;
	}
function ( ) { var pkg = utils . extend ( { } , this . orig ) ; var isFlat = this . context . isFlatFileStructure ; var fileUrl = this . pkg . fileUrl ; var context = this . context ; if ( isFlat && ! pkg . __crawledNestedPosition ) { pkg . __crawledNestedPosition = true ; pkg . nextFileUrl = pkg . nestedFileUrl ; } else { // make sure we aren't loading something we've already loaded var parentAddress = utils . path . parentNodeModuleAddress ( fileUrl ) ; if ( ! parentAddress ) { throw new Error ( 'Did not find ' + pkg . origFileUrl ) ; } var nodeModuleAddress = parentAddress + "/" + pkg . name + "/package.json" ; pkg . nextFileUrl = nodeModuleAddress ; } return pkg ; }
Get the next package to look up by traversing up the node_modules.
Create a new pkg by extending the existing one
Get the next package to look up by traversing up the node_modules . Create a new pkg by extending the existing one