<commit_before>// dependencies -------------------------------------------------------

import React from 'react';

let Upload = React.createClass({

// life cycle events --------------------------------------------------

	componentDidMount: function () {
		this.getDOMNode().setAttribute('webkitdirectory', true);
		this.getDOMNode().setAttribute('directory', true);
	},

	render: function () {
		let self = this;
		return (
			<input type="file"  className="dirUpload-btn" onChange={self._onFileSelect} />
    	);
	},

// custom methods -----------------------------------------------------

	_onChange: function (e) {
		this.props.onChange(e);
	},

	_onFileSelect: function (e) {
		let files = e.target.files;
		this.props.onChange(this._generateFileTree(files));
	},

	_generateFileTree: function (files) {
		let pathList = [];
		var dirTree  = {};

		// generate list of paths
		for (let i = 0; i < files.length; i++) {
			let file = files[i];
            pathList.push(file.webkitRelativePath);
        }

        // build path from list
        for (let i = 0; i < pathList.length; i++) {
        	let path = pathList[i];
        	let pathParts = path.split('/');
        	var subObj = dirTree;
        	for (let j = 0; j < pathParts.length; j++) {
        		let part = pathParts[j];
        		if (!subObj[part]) {
        			subObj[part] = j < pathParts.length - 1 ? {} : path;
        		}
        		subObj = subObj[part];
        	}
        }

        // convert dirTree to array structure
        function objToArr (obj) {
			var arr = [];
			for (let key in obj) {
				if (typeof obj[key] != 'object') {
					arr.push({name: key, type: 'file', path: obj[key]})
				} else {
					arr.push({name: key, type: 'folder', children: objToArr(obj[key])});
				}
			}
			return arr;
		}

		dirTree = objToArr(dirTree);

        // return tree
        return dirTree;
	}

});

export default Upload;<commit_msg>Changed vars to lets to enforce stricter variable scoping<commit_after>// dependencies -------------------------------------------------------

import React from 'react';

let Upload = React.createClass({

// life cycle events --------------------------------------------------

	componentDidMount: function () {
		this.getDOMNode().setAttribute('webkitdirectory', true);
		this.getDOMNode().setAttribute('directory', true);
	},

	render: function () {
		let self = this;
		return (
			<input type="file"  className="dirUpload-btn" onChange={self._onFileSelect} />
    	);
	},

// custom methods -----------------------------------------------------

	_onChange: function (e) {
		this.props.onChange(e);
	},

	_onFileSelect: function (e) {
		let files = e.target.files;
		this.props.onChange(this._generateFileTree(files));
	},

	_generateFileTree: function (files) {
		let pathList = [];
		let dirTree  = {};

		// generate list of paths
		for (let i = 0; i < files.length; i++) {
			let file = files[i];
            pathList.push(file.webkitRelativePath);
        }

        // build path from list
        for (let i = 0; i < pathList.length; i++) {
        	let path = pathList[i];
        	let pathParts = path.split('/');
        	let subObj = dirTree;
        	for (let j = 0; j < pathParts.length; j++) {
        		let part = pathParts[j];
        		if (!subObj[part]) {
        			subObj[part] = j < pathParts.length - 1 ? {} : path;
        		}
        		subObj = subObj[part];
        	}
        }

        // convert dirTree to array structure
        function objToArr (obj) {
			let arr = [];
			for (let key in obj) {
				if (typeof obj[key] != 'object') {
					arr.push({name: key, type: 'file', path: obj[key]})
				} else {
					arr.push({name: key, type: 'folder', children: objToArr(obj[key])});
				}
			}
			return arr;
		}

		dirTree = objToArr(dirTree);

        // return tree
        return dirTree;
	}

});

export default Upload;
{'fraction_non_alphanumeric': 0.21808785529715763, 'fraction_numerical': 0.0020671834625322996, 'mean_word_length': 1.8152727272727274, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, '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': '6340800', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1179, 'n_words': 297}