<commit_before>import _ from "../helpers";
import { HTML } from "../constants";
import { $Element } from "../types";

/* es6-transpiler has-iterators:false, has-generators: false */

var reSpace = /[\n\t\r]/g;

function makeClassesMethod(nativeMethodName, fallback) {
    var methodName = nativeMethodName === "contains" ? "hasClass" : nativeMethodName + "Class";
    // use fallback if browser does not support classList API
    if (!HTML.classList) nativeMethodName = null;

    if (methodName === "hasClass" || methodName === "toggleClass") {
        return function(className, force) {
            var node = this[0];

            if (node) {
                if (typeof force === "boolean") {
                    this[force ? "addClass" : "removeClass"](className);

                    return force;
                }

                if (nativeMethodName) {
                    return node.classList[nativeMethodName](className);
                } else {
                    return fallback(node, className);
                }
            }
        };
    } else {
        return function(className) {
            var node = this[0],
                args = arguments;

            if (node) {
                for (className of args) {
                    if (nativeMethodName) {
                        node.classList[nativeMethodName](className);
                    } else {
                        fallback(node, className);
                    }<commit_msg>throw errors id className is not a string<commit_after>import { MethodError } from "../errors";
import { HTML } from "../constants";
import { $Element } from "../types";

/* es6-transpiler has-iterators:false, has-generators: false */

var reSpace = /[\n\t\r]/g;

function makeClassesMethod(nativeMethodName, fallback) {
    var methodName = nativeMethodName === "contains" ? "hasClass" : nativeMethodName + "Class";
    // use fallback if browser does not support classList API
    if (!HTML.classList) nativeMethodName = null;

    if (methodName === "hasClass" || methodName === "toggleClass") {
        return function(className, force) {
            var node = this[0];

            if (node) {
                if (typeof force === "boolean" && methodName === "toggleClass") {
                    this[force ? "addClass" : "removeClass"](className);

                    return force;
                }

                if (typeof className !== "string") throw new MethodError(methodName);

                if (nativeMethodName) {
                    return node.classList[nativeMethodName](className);
                } else {
                    return fallback(node, className);
                }
            }
        };
    } else {
        return function(className) {
            var node = this[0],
                args = arguments;

            if (node) {
                for (className of args) {
                    if (typeof className !== "string") throw new MethodError(methodName);

                    if (nativeMethodName) {
                        node.classList[nativeMethodName](className);
                    } else {
                        fallback(node, className);
                    }
{'fraction_non_alphanumeric': 0.11585557299843015, 'fraction_numerical': 0.0018838304552590266, 'mean_word_length': 1.6330578512396694, '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': '5300475', 'n_tokens_mistral': 801, 'n_tokens_neox': 764, 'n_words': 206}