<commit_before>'use strict';

var Demo = React.createClass({
	render: function () {
		function createList(text, its, index) {
			return <Describe text={text} its={its} key={index} />;
		}

		var items = Object.keys(this.props.describes).map(function (describe, index) {
			return createList(describe, this.props.describes[describe], index);
		}, this);

		return <ul>{items}</ul>;
	}
});

var Describe = React.createClass({
	getInitialState: function () {
		return { visible: false };
	},
	toggle: function (e) {
		e.preventDefault();
		this.setState({ visible: !this.state.visible });
	},
	render: function () {
		if (this.state.visible) {
			function createIt(text, source, index) {
				return <It text={text} source={source} key={index} />;
			}

			var items = Object.keys(this.props.its).map(function (it, index) {
				return createIt(it, this.props.its[it], index);
			}, this);

			return <div>
				<div
					className="describe"
					onClick={this.toggle}
				>{this.props.text}</div>
				<ul>{items}</ul>
			</div>;
		} else {
			return <div>
				<div
					className="describe"
					onClick={this.toggle}
				>{this.props.text}</div>
			</div>;
		}
	}
});

var It = React.createClass({
	getInitialState: function () {
		return { result: null };
	},
	ev: function (e) {
		e.preventDefault();

		var tree = esprima.parse(this.props.source);
		jinter.processLiterals(tree);
		jinter.processVars(tree);

		var resultRaw = jinter.ev(tree, jinter.EMPTY);

		var result = resultRaw ?
			resultRaw.toString() :
			'undefined';

		this.setState({ result: result });
	},
	rawHljs: function (source) {
		var highlight = hljs.highlight('javascript', source, false);
		return { __html: highlight.value };
	},
	render: function () {
		return <li onClick={this.ev}>
			<div className="it text">{this.props.text}</div>
			<pre
				className="hljs source"
				dangerouslySetInnerHTML={this.rawHljs(this.props.source)}
			/>
			<pre
				className="hljs source result"
			>{this.state.result || "click to eval"}
			</pre>
		</li>;
	}
});

React.render(<Demo describes={window.snippets} />, document.getElementById('container'));<commit_msg>Evaluates both using jinter and js to compare<commit_after>'use strict';

var Demo = React.createClass({
	render: function () {
		function createList(text, its, index) {
			return <Describe text={text} its={its} key={index} />;
		}

		var items = Object.keys(this.props.describes).map(function (describe, index) {
			return createList(describe, this.props.describes[describe], index);
		}, this);

		return <ul>{items}</ul>;
	}
});

var Describe = React.createClass({
	getInitialState: function () {
		return { visible: false };
	},
	toggle: function (e) {
		e.preventDefault();
		this.setState({ visible: !this.state.visible });
	},
	render: function () {
		if (this.state.visible) {
			function createIt(text, source, index) {
				return <It text={text} source={source} key={index} />;
			}

			var items = Object.keys(this.props.its).map(function (it, index) {
				return createIt(it, this.props.its[it], index);
			}, this);

			return <div>
				<div
					className="describe"
					onClick={this.toggle}
				>{this.props.text}</div>
				<ul>{items}</ul>
			</div>;
		} else {
			return <div>
				<div
					className="describe"
					onClick={this.toggle}
				>{this.props.text}</div>
			</div>;
		}
	}
});

var It = React.createClass({
	getInitialState: function () {
		return {
			resultJinter: null,
			resultJs: null
		};
	},
	evJs: function (source) {
		var resultRaw = eval(source);

		return resultRaw ?
			resultRaw.toString() :
			'undefined';
	},
	evJinter: function (source) {
		var tree = esprima.parse(this.props.source);
		jinter.processLiterals(tree);
		jinter.processVars(tree);

		var resultRaw = jinter.ev(tree, jinter.EMPTY);

		return resultRaw ?
			resultRaw.toString() :
			'undefined';
	},
	ev: function (e) {
		e.preventDefault();

		this.setState({
			resultJinter: this.evJinter(this.props.source),
			resultJs: this.evJs(this.props.source)
		});
	},
	rawHljs: function (source) {
		var highlight = hljs.highlight('javascript', source, false);
		return { __html: highlight.value };
	},
	render: function () {
		var message = this.state.resultJinter ?
			"jinter: " + this.state.resultJinter + "; js: " + this.state.resultJs :
			"click to eval";
		return <li onClick={this.ev}>
			<div className="it text">{this.props.text}</div>
			<pre
				className="hljs source"
				dangerouslySetInnerHTML={this.rawHljs(this.props.source)}
			/>
			<pre
				className="hljs source result"
			>{message}</pre>
		</li>;
	}
});

React.render(<Demo describes={window.snippets} />, document.getElementById('container'));
{'fraction_non_alphanumeric': 0.1718515340055782, 'fraction_numerical': 0.0, 'mean_word_length': 3.643426294820717, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, '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': '608751', 'n_tokens_mistral': 1836, 'n_tokens_neox': 1581, 'n_words': 322}