<commit_before>import {IMPORT, COMMENT, RULESET, DECLARATION} from './Enum.js'
import {sizeof} from './Utility.js'

// TODO: Remove this comment
// Example Use:
// serialize(compile(``), stringify) // default
// serialize(compile(``), middleware([prefixer, stringify])) // middlware
// function prefixer (current, callback) { if (current.type === DECLARATION) current.value = prefix(current.value) }

/**
 * @param {object[]} current
 * @param {function} callack
 * @return {string}
 */
export function serialize (current, callback) {
	var output = ''
	var length = sizeof(current)

	for (var i = 0; i < length; i++)
		output += callback(current[i], callback)

	return output
}

/**
 * @param {object[]} current
 * @param {function} callback
 * @return {string}
 */
export function stringify (current, callback) {
	var value = current.value
	var props = current.props
	var children = current.children

	switch (current.type) {
		case IMPORT: case DECLARATION:
			return value + ';'
		case COMMENT:
			return ''
		case RULESET:
			value = props.join(',')
	}

	return sizeof(children) ? value + '{' + serialize(children, stringify) + '}' : ''
}

/**
 * @param {string} current
 * @param {string} prefix
 * @param {string} suffix
 * @return {string}
 */
export function content (current, prefix, suffix) {
	return strlen(value) > 0 ? prefix + value + suffix : ''
}

/**
 * @param {function[]} current
 * @return {function}
 */
export function middleware (current) {
	var length = sizeof(current)

	return function (current, callback) {
		var output = ''
		var string = ''

		for (var i = 0; i < length; i++)
			if (string = current[i](current, callback))
				output += string

		return output
	}
}<commit_msg>eslint fix<commit_after>import {IMPORT, COMMENT, RULESET, DECLARATION} from './Enum.js'
import {sizeof, strlen} from './Utility.js'

// TODO: Remove this comment
// Example Use:
// serialize(compile(``), stringify) // default
// serialize(compile(``), middleware([prefixer, stringify])) // middlware
// function prefixer (current, callback) { if (current.type === DECLARATION) current.value = prefix(current.value) }

/**
 * @param {object[]} current
 * @param {function} callack
 * @return {string}
 */
export function serialize (current, callback) {
	var output = ''
	var length = sizeof(current)

	for (var i = 0; i < length; i++)
		output += callback(current[i], callback)

	return output
}

/**
 * @param {object[]} current
 * @param {function} callback
 * @return {string}
 */
export function stringify (current, callback) {
	var value = current.value
	var props = current.props
	var children = current.children

	switch (current.type) {
		case IMPORT: case DECLARATION:
			return value + ';'
		case COMMENT:
			return ''
		case RULESET:
			value = props.join(',')
	}

	return sizeof(children) ? value + '{' + serialize(children, callback) + '}' : ''
}

/**
 * @param {string} current
 * @param {string} prefix
 * @param {string} suffix
 * @return {string}
 */
export function content (current, prefix, suffix) {
	return strlen(current) > 0 ? prefix + current + suffix : ''
}

/**
 * @param {function[]} current
 * @return {function}
 */
export function middleware (current) {
	var length = sizeof(current)

	return function (current, callback) {
		var output = ''
		var string = ''

		for (var i = 0; i < length; i++)
			if (string = current[i](current, callback))
				output += string

		return output
	}
}
{'fraction_non_alphanumeric': 0.15994152046783625, 'fraction_numerical': 0.0017543859649122807, 'mean_word_length': 3.852482269503546, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4580127', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1080, 'n_words': 328}