<commit_before>/* Licensed under the Apache License, Version 2.0. © 2016 <NAME> <<EMAIL>> */
'use strict'

const escapeHtml = require('escape-html');

class SatoriServer {
	constructor() {
		this.html = this.createTagFactories(this.constructor.TAGS);
		Object.assign(this, this.html);
		this.Key = this.constructor.Key;
	}

	createTagFactories(tags, obj) {
		obj = obj || {};
		tags.forEach(tag => {obj[tag] = (modifiers, content) => this.create(tag, modifiers, content)});
		return obj;
	}

	create(tag, modifiers, content) {
		if (modifiers === null || typeof modifiers !== 'object' || modifiers.constructor !== Object) {
			if (content) {
				throw new Error('Invalid arguments');
			}

			content = modifiers;
			modifiers = {};
		}

		let attrs = [];

		if (modifiers.class) {
			attrs.push(this.class(modifiers.class));
		}

		if (modifiers.attr) {
			attrs.push(this.attr(modifiers.attr));
		}

		if (modifiers.data) {
			attrs.push(this.data(modifiers.data));
		}

		if (modifiers.css) {
			attrs.push(this.css(modifiers.css));
		}

		if (modifiers.bind) {
			attrs.push(this.bind(modifiers.bind, modifiers));
		}

		if (modifiers.list) {
			content = this.list(modifiers.list);
		}

		content = this.getValue(content != null ? content : modifiers.content);
		let hasContent = content != null;
		let contentSafe;

		if (hasContent) {
			if (content instanceof Array) {
				contentSafe = content.map(conditionalEscape).join('');
			} else {
				contentSafe = conditionalEscape(content);
			}
		}

		return new SafeString('<' + tag + (attrs.length ? ' ' + attrs.join(' ') : '') +
			(hasContent ? '>' + contentSafe + '</' + tag + '>' : '/>'));
	}

	class(classes) {
		let classesStr = '';

		if (typeof classes !== 'object') {
			classesStr += escapeHtml(classes);
		} else if (classes instanceof Array) {
			classesStr = escapeHtml(classes.join(' '));
		} else {
			for (let cls in classes) {
				if (this.getValue(classes[cls])) {
					classesStr += (classesStr ? ' ' : '') + escapeHtml(cls);
				}
			}<commit_msg>Rename a variable<commit_after>/* Licensed under the Apache License, Version 2.0. © 2016 <NAME> <<EMAIL>> */
'use strict'

const escapeHtml = require('escape-html');

class SatoriServer {
	constructor() {
		this.html = this.createTagFactories(this.constructor.TAGS);
		Object.assign(this, this.html);
		this.Key = this.constructor.Key;
	}

	createTagFactories(tags, obj) {
		obj = obj || {};
		tags.forEach(tag => {obj[tag] = (modifiers, content) => this.create(tag, modifiers, content)});
		return obj;
	}

	create(tag, modifiers, content) {
		if (modifiers === null || typeof modifiers !== 'object' || modifiers.constructor !== Object) {
			if (content) {
				throw new Error('Invalid arguments');
			}

			content = modifiers;
			modifiers = {};
		}

		let attrs = [];

		if (modifiers.class) {
			attrs.push(this.class(modifiers.class));
		}

		if (modifiers.attr) {
			attrs.push(this.attr(modifiers.attr));
		}

		if (modifiers.data) {
			attrs.push(this.data(modifiers.data));
		}

		if (modifiers.css) {
			attrs.push(this.css(modifiers.css));
		}

		if (modifiers.bind) {
			attrs.push(this.bind(modifiers.bind, modifiers));
		}

		if (modifiers.list) {
			content = this.list(modifiers.list);
		}

		content = this.getValue(content != null ? content : modifiers.content);
		let hasContent = content != null;
		let escapedContent;

		if (hasContent) {
			if (content instanceof Array) {
				escapedContent = content.map(conditionalEscape).join('');
			} else {
				escapedContent = conditionalEscape(content);
			}
		}

		return new SafeString('<' + tag + (attrs.length ? ' ' + attrs.join(' ') : '') +
			(hasContent ? '>' + escapedContent + '</' + tag + '>' : '/>'));
	}

	class(classes) {
		let classesStr = '';

		if (typeof classes !== 'object') {
			classesStr += escapeHtml(classes);
		} else if (classes instanceof Array) {
			classesStr = escapeHtml(classes.join(' '));
		} else {
			for (let cls in classes) {
				if (this.getValue(classes[cls])) {
					classesStr += (classesStr ? ' ' : '') + escapeHtml(cls);
				}
			}
{'fraction_non_alphanumeric': 0.17331363860167406, 'fraction_numerical': 0.0029542097488921715, 'mean_word_length': 3.45993413830955, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, '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': '992661', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1350, 'n_words': 280}