<commit_before>import {agents} from './user-agents';
import {clone, assign, map, flatten, findKey, forEach, find} from 'lodash';

module.exports = function normalizeBrowsers(browsers) {

	return new Promise((resolve, reject) => {

		//reject(err);
		let data = browsers;
		resolve(data);

	});
}<commit_msg>added function to calculate browser shares<commit_after>import {agents} from './user-agents';
import {clone, assign, map, flatten, findKey, forEach, find, head} from 'lodash';

module.exports = function normalizeBrowsers(browsers) {

	return new Promise((resolve, reject) => {
		let unknownBrowsersList = [];
		let validBrowsersList = [];

		const calculateShares = function(browsers) {

			const getSum = function(browsers) {
				let sum = 0;
				forEach(browsers, (browser) => {
					let val = browser.count;
					sum += val;
				});
				return sum;
			}
			const sum = getSum(browsers);

			return browsers.map((browser) => {
				let browserN = browser;
				browserN.share = browserN.count / sum;
				return browserN;
			});

		};

		if(head(browsers).count >= 1) {


			//browsers = calculateShares(browsers);

		}

		//for
		
/*
		findName();
			if found

			else
				findNameSiblings
					> unknownList.push(items);
*/




		//reject(err);
		let data = calculateShares(browsers);
		resolve(data);

	});
}
{'fraction_non_alphanumeric': 0.1427486712224753, 'fraction_numerical': 0.0015186028853454822, 'mean_word_length': 3.408026755852843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1667769', 'n_tokens_mistral': 528, 'n_tokens_neox': 429, 'n_words': 104}