<commit_before>export function asArray(element) {
	if (Array.isArray(element)) {
		return element;
	}
	if (element.props && element.props.children) {
		return asArray(element.props.children);
	} else {
		return [element];
	}
}


export function forEachChildElement(dataModel, callback) {
	if (Array.isArray(dataModel.props.children)) {
		for (const child of dataModel.props.children) {
			if (child) {
				const stop = callback(child);
				if (stop === true) {
					return true;
				}
			}
		}
		return false;
	} else {
		return dataModel.props.children ? callback(dataModel.props.children) : false;
	}
}


export function forEachChildElementRecursive(dataModel, callback) {
	return forEachChildElement(dataModel, child => {
		if (!child) {
			return false;
		}
		const stop = callback(child);
		if (stop === true) {
			return true;
		}
		return forEachChildElementRecursive(child, callback);
	});
}


export function findChildElement(dataModel, name) {
	let result = null;
	forEachChildElement(dataModel, element => {
		if (!element) {
			return false;
		}
		const found = element.props.name === name;
		result = element;
		return found;
	});
	return result;
}


export function childNames(dataModel) {
	const result = [];
	forEachChildElement(dataModel, element => {
		if (!element) {
			return;
		}
		const { props, type } = element;
		if (props === undefined) {
			return;
		}
		if (type.dataModelType && props.name) {
			result.push(props.name);
		} else if (props.children) {
			result.push(...childNames(element));
		}
	});
	return result;
}


export function getPropsAndValues(dataModel, data, callback) {
	const table = [];
	forEachChildElement(dataModel, element => {
		if (!element) {
			return;
		}
		const { props, type } = element;
		if (props === undefined) {
			return;
		}
		if (type.dataModelType && props.name) {
			let value;
			if (data.hasOwnProperty(props.name)) {
				value = data[props.name];
			} else {
				value = type.dynamicDefaultValue ? type.dynamicDefaultValue(props) : props.defaultValue;
			}
			callback({...props, value});
		} else if (props.children) {
			getPropsAndValues(element, data, callback);
		}
	});
	return table;
}


export function assignData(dataModel, source, destination = {}) {<commit_msg>getPropsAndValues -> callback(props, value)<commit_after>export function asArray(element) {
	if (Array.isArray(element)) {
		return element;
	}
	if (element.props && element.props.children) {
		return asArray(element.props.children);
	} else {
		return [element];
	}
}


export function forEachChildElement(dataModel, callback) {
	if (Array.isArray(dataModel.props.children)) {
		for (const child of dataModel.props.children) {
			if (child) {
				const stop = callback(child);
				if (stop === true) {
					return true;
				}
			}
		}
		return false;
	} else {
		return dataModel.props.children ? callback(dataModel.props.children) : false;
	}
}


export function forEachChildElementRecursive(dataModel, callback) {
	return forEachChildElement(dataModel, child => {
		if (!child) {
			return false;
		}
		const stop = callback(child);
		if (stop === true) {
			return true;
		}
		return forEachChildElementRecursive(child, callback);
	});
}


export function findChildElement(dataModel, name) {
	let result = null;
	forEachChildElement(dataModel, element => {
		if (!element) {
			return false;
		}
		const found = element.props.name === name;
		result = element;
		return found;
	});
	return result;
}


export function childNames(dataModel) {
	const result = [];
	forEachChildElement(dataModel, element => {
		if (!element) {
			return;
		}
		const { props, type } = element;
		if (props === undefined) {
			return;
		}
		if (type.dataModelType && props.name) {
			result.push(props.name);
		} else if (props.children) {
			result.push(...childNames(element));
		}
	});
	return result;
}


export function getPropsAndValues(dataModel, data, callback) {
	const table = [];
	forEachChildElement(dataModel, element => {
		if (!element) {
			return;
		}
		const { props, type } = element;
		if (props === undefined) {
			return;
		}
		if (type.dataModelType && props.name) {
			let value;
			if (data.hasOwnProperty(props.name)) {
				value = data[props.name];
			} else {
				value = type.dynamicDefaultValue ? type.dynamicDefaultValue(props) : props.defaultValue;
			}
			callback(props, value);
		} else if (props.children) {
			getPropsAndValues(element, data, callback);
		}
	});
	return table;
}


export function assignData(dataModel, source, destination = {}) {
{'fraction_non_alphanumeric': 0.13744180891154956, 'fraction_numerical': 0.0, 'mean_word_length': 3.709812108559499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '857142', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1456, 'n_words': 332}