<commit_before>// specification nodes
'use strict';

var types = require ('./types');

/**
 * build spec node
 * expand macros
 *  except when the returned node is itself a macro
 * @param type the type of the returned spec node
 *  all other arguments are added as node items
 *  macros are expanded
 * @returns {Array} the spec node, where the first element
 *  is the type
 */
function specNode (type) {
	return expandSub ([type], arguments);
}

/**
 * push node items onto the spec node array
 * expand macros
 * @param {Array} sub the spec node array to be generated
 * @param args node items
 * @returns {Array} the spec node array,
 *  with the items appended
 */
function expandSub (sub, args) {
	var i;
	var n = args.length;
	var arg;
	for (i = 1; i < n; i++) {
		arg = args [i];
		if (arg [0] === types.MACRO) {
			expandSub (sub, arg);
		} else {
			sub.push (arg);
		}
	}
	return sub;
}

/**
 * create node builder
 * @param type the type of spec nodes to generate
 * @returns {function(this:null)} a function that will return
 *  a spec node of the specified type,
 *  and with the items provided the function as argument
 */
function nodeBuilder (type) {
	return specNode.bind (null, type);
}

/**
 * macro node builder
 * @type {function(this:null)}
 */
var macro = nodeBuilder (types.MACRO);

module.exports = {
	specNode: specNode,
	nodeBuilder: nodeBuilder,
	macro: macro
};<commit_msg>nodeBuilder uses closure instead of bind<commit_after>// specification nodes
'use strict';

var types = require ('./types');

/**
 * build spec node
 * expand macros
 *  except when the returned node is itself a macro
 * @param type the type of the returned spec node
 *  all other arguments are added as node items
 *  macros are expanded
 * @returns {Array} the spec node, where the first element
 *  is the type
 */
function specNode (type) {
	return expandSub ([type], arguments);
}

/**
 * push node items onto the spec node array
 * expand macros
 * @param {Array} sub the spec node array to be generated
 * @param args node items
 * @returns {Array} the spec node array,
 *  with the items appended
 */
function expandSub (sub, args) {
	var i;
	var n = args.length;
	var arg;
	for (i = 1; i < n; i++) {
		arg = args [i];
		if (arg [0] === types.MACRO) {
			expandSub (sub, arg);
		} else {
			sub.push (arg);
		}
	}
	return sub;
}

/**
 * create node builder
 * @param type the type of spec nodes to generate
 * @returns {Function} a function that will return
 *  a spec node of the specified type,
 *  and with the items provided to the function as argument
 */
function nodeBuilder (type) {
	return function buildNode () {
		return expandSub ([type], arguments);
	};
}

/**
 * macro node builder
 * @type {function(this:null)}
 */
var macro = nodeBuilder (types.MACRO);

module.exports = {
	specNode: specNode,
	nodeBuilder: nodeBuilder,
	macro: macro
};
{'fraction_non_alphanumeric': 0.11475409836065574, 'fraction_numerical': 0.0013951866062085804, 'mean_word_length': 3.4191063174114023, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2044996', 'n_tokens_mistral': 907, 'n_tokens_neox': 876, 'n_words': 381}