<commit_before>/** @license MIT License (c) copyright <NAME> & <NAME> */

(function (define) {
define(function () {

	var forEach, slice;

	forEach = Array.prototype.forEach;
	slice = Array.prototype.slice;

	return {
		getValues: formToObject,
		getMultiSelectValue: getMultiSelectValue,
		setValues: objectToForm,
		setElementValue: setElementValue,
		setGroupValue: setGroupValue,
		setMultiSelectValue: setMultiSelectValue,
		isCheckable: isCheckable
	};

	function objectToForm(form, object, filter) {
		var els;

		els = form.elements;
		if(typeof filter !== 'function') {
			filter = alwaysInclude;
		}

		Object.keys(object).forEach(function(name) {

			var el, value;

			value = object[name];
			el = els[name];

			if(!filter(el, name, value)) return;

			if(el.length) {
				setGroupValue(el, value);
			} else {
				setElementValue(el, value);
			}

		});

		return form;
	}

	function setGroupValue(group, value) {
		var getBooleanValue;

		getBooleanValue = Array.isArray(value)
			? function(array, el) { return array.indexOf(el.value) >= 0; }
			: function(value, el) { return el.value == value; };

		forEach.call(group, function(el, i) {
			if(isCheckable(el)) {
				el.checked = getBooleanValue(value, el);
			} else {
				el.value = textValue(value[i]);
			}
		});
	}

	function setElementValue(el, value) {

		if(isCheckable(el)) {

			el.checked = !!value;<commit_msg>Fix single select handling in objectToForm<commit_after>/** @license MIT License (c) copyright <NAME> & <NAME> */

(function (define) {
define(function () {

	var forEach, slice;

	forEach = Array.prototype.forEach;
	slice = Array.prototype.slice;

	return {
		getValues: formToObject,
		getMultiSelectValue: getMultiSelectValue,
		setValues: objectToForm,
		setElementValue: setElementValue,
		setGroupValue: setGroupValue,
		setMultiSelectValue: setMultiSelectValue,
		isCheckable: isCheckable
	};

	function objectToForm(form, object, filter) {
		var els;

		els = form.elements;
		if(typeof filter !== 'function') {
			filter = alwaysInclude;
		}

		Object.keys(object).forEach(function(name) {

			var el, value;

			value = object[name];
			el = els[name];

			if(!filter(el, name, value)) return;

			if((el.length && el.type !== 'select-one') || (el.options && el.multiple)) {
				setGroupValue(el, value);
			} else {
				setElementValue(el, value);
			}

		});

		return form;
	}

	function setGroupValue(group, value) {
		var getBooleanValue;

		getBooleanValue = Array.isArray(value)
			? function(array, el) { return array.indexOf(el.value) >= 0; }
			: function(value, el) { return el.value == value; };

		forEach.call(group, function(el, i) {
			if(isCheckable(el)) {
				el.checked = getBooleanValue(value, el);
			} else {
				el.value = textValue(value[i]);
			}
		});
	}

	function setElementValue(el, value) {

		if(isCheckable(el)) {

			el.checked = !!value;
{'fraction_non_alphanumeric': 0.14240947075208912, 'fraction_numerical': 0.0006963788300835655, 'mean_word_length': 3.8530405405405403, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1395386', 'n_tokens_mistral': 1111, 'n_tokens_neox': 959, 'n_words': 206}