<commit_before>export function $(id) {
    if (id[0] === '#') {
        id = id.slice(1);
    }

    return document.getElementById(id);
}

export function $$(selector, ctx = document) {
    return ctx.querySelectorAll(selector);
}

export function listen(el, eventName, handler) {
    var elStr;

    if (typeof el === 'string') {
        [elStr, el] = [el, $$(el)[0]];
    }

    if (!el) {
        throw new Error('Could not addEventListener: element "' + elStr + '" did not exist!');
    }

    if (el.addEventListener) {
        el.addEventListener(eventName, handler, false);
    } else {
        el.attachEvent('on' + eventName, function() {
            handler.call(el);
        });
    }
}

export function addClass(el, name) {
    if (!el || !name || !(el instanceof Object) || el.className === void 0) {
        return;
    }

    if (el.classList) {
        el.classList.add(name);
        return;<commit_msg>DOM util $$ gives an array rather than NodeList<commit_after>export function $(id) {
    if (id[0] === '#') {
        id = id.slice(1);
    }

    return document.getElementById(id);
}

export function $$(selector, ctx = document) {
    return Array.prototype.slice.call(ctx.querySelectorAll(selector));
}

export function listen(el, eventName, handler) {
    var elStr;

    if (typeof el === 'string') {
        [elStr, el] = [el, $$(el)[0]];
    }

    if (!el) {
        throw new Error('Could not addEventListener: element "' + elStr + '" did not exist!');
    }

    if (el.addEventListener) {
        el.addEventListener(eventName, handler, false);
    } else {
        el.attachEvent('on' + eventName, function() {
            handler.call(el);
        });
    }
}

export function addClass(el, name) {
    if (!el || !name || !(el instanceof Object) || el.className === void 0) {
        return;
    }

    if (el.classList) {
        el.classList.add(name);
        return;
{'fraction_non_alphanumeric': 0.16334033613445378, 'fraction_numerical': 0.004201680672268907, 'mean_word_length': 2.4510869565217392, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2829970', 'n_tokens_mistral': 600, 'n_tokens_neox': 588, 'n_words': 148}