<commit_before>import { prefix } from './config';
import { toArray } from './util';
import SocialLikes from './social-likes';

// Symbol to store an instance reference in a DOM node
const symbol = 'socialLikes';

/**
 * Initialize Social Likes on a DOM element.
 *
 * @param {HTMLElement} elem DOM element.
 * @param {Object} [options] Options.
 * @return {SocialLikes}
 */
function init(elem, options = {}) {
	let instance = elem[symbol];
	if (instance) {
		instance.update(options);
	}
	else {
		elem[symbol] = new SocialLikes(elem, options);
	}
	return instance;
}

function autoInit(wait = false) {
	let elements = document.querySelectorAll(`.${prefix}`);
	if (elements) {
		toArray(elements).forEach(init);
	}
	else if (wait) {
		// No elements found. Wait for DOM content loaded to try again in case the script was included in the <head>.
		document.addEventListener('DOMContentLoaded', autoInit);
	}
}

// Auto initialization
autoInit(true);

// Expose
export default init;<commit_msg>Do not pass index as options to constructor.<commit_after>import { prefix } from './config';
import { toArray } from './util';
import SocialLikes from './social-likes';

// Symbol to store an instance reference in a DOM node
const symbol = 'socialLikes';

/**
 * Initialize Social Likes on a DOM element.
 *
 * @param {HTMLElement} elem DOM element.
 * @param {Object} [options] Options.
 * @return {SocialLikes}
 */
function init(elem, options = {}) {
	let instance = elem[symbol];
	if (instance) {
		instance.update(options);
	}
	else {
		elem[symbol] = new SocialLikes(elem, options);
	}
	return instance;
}

function autoInit(wait = false) {
	let elements = document.querySelectorAll(`.${prefix}`);
	if (elements) {
		toArray(elements).forEach(elem => init(elem));
	}
	else if (wait) {
		// No elements found. Wait for DOM content loaded to try again in case the script was included in the <head>.
		document.addEventListener('DOMContentLoaded', autoInit);
	}
}

// Auto initialization
autoInit(true);

// Expose
export default init;
{'fraction_non_alphanumeric': 0.13454903893543618, 'fraction_numerical': 0.0, 'mean_word_length': 4.139240506329114, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '5651842', 'n_tokens_mistral': 622, 'n_tokens_neox': 616, 'n_words': 207}