<commit_before>// flattens a bundle graph
var winston = require('winston');
var name = require('./name');
var size = require('../node/size');
var bundle = {
		/**
		 * Flattens the list of shares until each script has a minimal depth
		 * @param {Object} shares
		 * @param {Object} depth
		 */
		flatten : function(shares, depth){
			// make waste object
			// mark the size
			while(bundle.maxDepth(shares) > depth){
				var min = bundle.min(shares);
				bundle.merge(shares, min);
			}
		},
		/**
		 * Merges 2 shares contents.  Shares are expected to be in the order
		 * getMostShared removes them ... by lowest depenency first.
		 * We should merge into the 'lower' dependency.
		 * 
		 * @param {Object} shares
		 * @param {Object} min
		 *     
		 *     diff : {app1 : waste, app2 : waste, _waste: 0}, 
		 *     lower: i, - the 'lower' share whos contents will be merged into, and contents should run first
		 *     higher: j  - the 'higher' share
		 */
		merge: function(shares, min){
			var lower = shares[min.lower],
				upper = shares[min.higher];

			winston.debug("  flattening "+name.getName(upper.bundles)+">"+name.getName(lower.bundles));<commit_msg>Bundle flattening logging fix<commit_after>// flattens a bundle graph
var winston = require('winston');
var name = require('./name');
var size = require('../node/size');
var bundle = {
		/**
		 * Flattens the list of shares until each script has a minimal depth
		 * @param {Object} shares
		 * @param {Object} depth
		 */
		flatten : function(shares, depth){
			// make waste object
			// mark the size
			while(bundle.maxDepth(shares) > depth){
				var min = bundle.min(shares);
				bundle.merge(shares, min);
			}
		},
		/**
		 * Merges 2 shares contents.  Shares are expected to be in the order
		 * getMostShared removes them ... by lowest depenency first.
		 * We should merge into the 'lower' dependency.
		 * 
		 * @param {Object} shares
		 * @param {Object} min
		 *     
		 *     diff : {app1 : waste, app2 : waste, _waste: 0}, 
		 *     lower: i, - the 'lower' share whos contents will be merged into, and contents should run first
		 *     higher: j  - the 'higher' share
		 */
		merge: function(shares, min){
			var lower = shares[min.lower],
				upper = shares[min.higher];

			winston.debug("  flattening "+name.getName(upper)+">"+name.getName(lower));
{'fraction_non_alphanumeric': 0.13367609254498714, 'fraction_numerical': 0.003427592116538132, 'mean_word_length': 2.8916666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5682117', 'n_tokens_mistral': 836, 'n_tokens_neox': 702, 'n_words': 244}