function generateUsageStats( modules ) {
	function getCamelCasedDepName( dep ) {
		return dep
			.split( '/' )
			.map( function( part ) {
				return _.camelCase( part );
			} )
			.join( '/' );
	}
	return Object.keys( modules ).reduce( function( target, moduleName ) {
		var deps = modules[ moduleName ];
		deps.forEach( function( dependency ) {
			const camelCasedDepName = getCamelCasedDepName( dependency );
			if ( ! target[ camelCasedDepName ] ) {
				target[ camelCasedDepName ] = { count: 0 };
			}
			target[ camelCasedDepName ].count += 1;
		} );
		return target;
	}, {} );
}
function generateUsageStats( modules ) {
	function getCamelCasedDepName( dep ) {
		return dep
			.split( '/' )
			.map( function( part ) {
				return _.camelCase( part );
			} )
			.join( '/' );
	}
	return Object.keys( modules ).reduce( function( target, moduleName ) {
		var deps = modules[ moduleName ];
		deps.forEach( function( dependency ) {
			const camelCasedDepName = getCamelCasedDepName( dependency );
			if ( ! target[ camelCasedDepName ] ) {
				target[ camelCasedDepName ] = { count: 0 };
			}
			target[ camelCasedDepName ].count += 1;
		} );
		return target;
	}, {} );
}
function generateUsageStats ( modules ) { function getCamelCasedDepName ( dep ) { return dep . split ( '/' ) . map ( function ( part ) { return _ . camelCase ( part ) ; } ) . join ( '/' ) ; } return Object . keys ( modules ) . reduce ( function ( target , moduleName ) { var deps = modules [ moduleName ] ; deps . forEach ( function ( dependency ) { const camelCasedDepName = getCamelCasedDepName ( dependency ) ; if ( ! target [ camelCasedDepName ] ) { target [ camelCasedDepName ] = { count : 0 } ; } target [ camelCasedDepName ] . count += 1 ; } ) ; return target ; } , { } ) ; }
Given an object of modules with dependencies
generate a stats object with the usage counts:
{
'A': { count: 2 },
'B': { count: 10 }
}
@param {object} modules An object of modules with dependencies
@returns {object} An object with the usage stats for each dependency
Given an object of modules with dependencies generate a stats object with the usage counts : { A : { count : 2 } B : { count : 10 } }