<commit_before>import { $C } from '../deps/collection';
import { base } from '../consts/macros';
import { macroBlackSymbols } from '../consts/regs';

/**
 * Sets an object as macros
 *
 * @param {(Object|undefined)} obj - the source object
 * @param {!Object} macros - a macro namespace object
 * @param {?string=} [opt_namespace] - a namespace for adding macros
 * @param {?boolean=} [opt_init] - if is true, then macros will be re/initialised
 */
export function setMacros(obj, macros, opt_namespace, opt_init) {
	if (opt_init) {
		$C.extend(false, macros, {
			map: {},
			groups: {},
			inline: {'\\': true},
			combo: {}
		});

		setMacros(base, macros);
	}

	if (obj == null) {
		$C(obj = macros.groups[opt_namespace]).forEach((el, key) => {
			delete obj[key];
			delete macros.map[key];
			delete macros.combo[key];
		});

	} else {
		$C(obj).forEach((el, key) => {
			if (key[0] === '@' && !opt_namespace) {
				setMacros(el, macros, key);

			} else {
				if (opt_namespace) {
					macros.groups[opt_namespace] = macros.groups[opt_namespace] || {};
				}

				if (el) {
					if (macroBlackSymbols.test(key)) {
						throw new Error(`Invalid macro "${key}"`);
					}

					macros.map[key] = el.value || el;

					if (Array.isArray(macros[key])) {
						macros.combo[key] = true;
					}

					const inline = el['inline'] || el.inline;

					if (inline) {
						macros.inline[key[0]] = true;
					}

					if (opt_namespace) {
						macros.groups[opt_namespace][key] = macros[key];
					}

				} else {
					delete macros.map[key];
					delete macros.combo[key];

					if (opt_namespace) {
						delete macros.groups[opt_namespace][key];
					}
				}
			}
		});
	}

	return macros;
}
<commit_msg>Bugfix<commit_after>import { $C } from '../deps/collection';
import { base } from '../consts/macros';
import { macroBlackSymbols } from '../consts/regs';

/**
 * Sets an object as macros
 *
 * @param {(Object|undefined)} obj - the source object
 * @param {!Object} macros - a macro namespace object
 * @param {?string=} [opt_namespace] - a namespace for adding macros
 * @param {?boolean=} [opt_init] - if is true, then macros will be re/initialised
 */
export function setMacros(obj, macros, opt_namespace, opt_init) {
	if (opt_init) {
		$C.extend(false, macros, {
			map: {},
			groups: {},
			inline: {'\\': true},
			combo: {}
		});

		setMacros(base, macros);
	}

	if (obj == null) {
		$C(obj = macros.groups[opt_namespace]).forEach((el, key) => {
			delete obj[key];
			delete macros.map[key];
			delete macros.combo[key];
		});

	} else {
		$C(obj).forEach((el, key) => {
			if (key[0] === '@' && !opt_namespace) {
				setMacros(el, macros, key);

			} else {
				if (opt_namespace) {
					macros.groups[opt_namespace] = macros.groups[opt_namespace] || {};
				}

				if (el) {
					if (macroBlackSymbols.test(key)) {
						throw new Error(`Invalid macro "${key}"`);
					}

					macros.map[key] = el.value || el;

					if (Array.isArray(macros[key])) {
						macros.combo[key] = true;
					}

					const inline = el['inline'] || el.inline;

					if (inline) {
						macros.inline[key[0]] = true;
					}

					if (opt_namespace) {
						macros.groups[opt_namespace][key] = macros.map[key];
					}

				} else {
					delete macros.map[key];
					delete macros.combo[key];

					if (opt_namespace) {
						delete macros.groups[opt_namespace][key];
					}
				}
			}
		});
	}

	return macros;
}

{'fraction_non_alphanumeric': 0.1778888562187592, 'fraction_numerical': 0.0011761246692149367, 'mean_word_length': 2.8224719101123594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5682145', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1183, 'n_words': 262}