<commit_before>﻿(function (name, definition) {
    if (typeof module != 'undefined') module.exports = definition();
    else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
    else {
        var noConflict = this[name];
        this[name] = definition();
        if (noConflict) this[name].noConflict = noConflict;
    }
}('transForm', function () {
    var _defaults = {
        attributeIgnore: 'data-transform-ignore',
        attributeText: 'data-transform-text',
        delimiter: '.',
        deserializeClean: true,
        inputs: ['input', 'select', 'textarea'],
        skipDisabled: true,
        skipFalsy: false,
        skipReadOnly: false,
        triggerChange: false,
        useIdOnEmptyName: true
    };

    /* Serialize */
    function serialize(formEl, options, nodeCallback) {
        var parent = makeElement(formEl),
            opts = getOptions(options),
            elements = getElements(parent, opts.skipDisabled, opts.skipReadOnly),
            result = {},
            el, entry, key, textKey;

        for (var i = 0, l = elements.length; i < l; i++) {
            el = elements[i];
            entry = null;

            if (textKey = el.getAttribute(_defaults.attributeText)) {
                var textEntry = getTextEntryFromInput(el, textKey);
                if (isValidValue(textEntry.value, opts.skipFalsy))
                    saveEntryToResult(result, textEntry, opts.delimiter);
            }
            if (!isInput(el)) continue;
            if (!(key = (el.name || opts.useIdOnEmptyName && el.id))) continue;
            if (nodeCallback) entry = nodeCallback(el, key);
            if (!entry) entry = getEntryFromInput(el, key);
            if (isValidValue(entry.value, opts.skipFalsy))
                saveEntryToResult(result, entry, opts.delimiter);
        }
        return result;
    }

    function isValidValue(value, skipFalsy) {
        return !(typeof value === 'undefined' || value === null || (skipFalsy && (!value || (isArray(value) && !value.length))));
    }

    function getEntryFromInput(el, key) {
        var nodeType = el.type && el.type.toLowerCase(), value;

        switch (nodeType) {
            case 'radio':
                if (el.checked)
                    value = el.value === 'on' ? true : el.value;
                break;
            case 'checkbox':
                value = el.checked ? (el.value === 'on' ? true : el.value) : false;
                break;
            case 'select-multiple':
                value = [];
                for (var i = 0, l = el.options.length; i < l; i++)
                    if (el.options[i].selected) value.push(el.options[i].value);
                break;
            case 'file':<commit_msg>⚡ Fix for #5<commit_after>﻿(function (name, definition) {
    if (typeof module != 'undefined') module.exports = definition();
    else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
    else {
        var noConflict = this[name];
        this[name] = definition();
        if (noConflict) this[name].noConflict = noConflict;
    }
}('transForm', function () {
    var _defaults = {
        attributeIgnore: 'data-transform-ignore',
        attributeText: 'data-transform-text',
        delimiter: '.',
        deserializeClean: true,
        inputs: ['input', 'select', 'textarea'],
        skipDisabled: true,
        skipFalsy: false,
        skipReadOnly: false,
        triggerChange: false,
        useIdOnEmptyName: true
    };

    /* Serialize */
    function serialize(formEl, options, nodeCallback) {
        var parent = makeElement(formEl),
            opts = getOptions(options),
            elements = getElements(parent, opts.skipDisabled, opts.skipReadOnly),
            result = {},
            el, entry, key, textKey;

        for (var i = 0, l = elements.length; i < l; i++) {
            el = elements[i];
            entry = null;

            if (textKey = el.getAttribute(_defaults.attributeText)) {
                var textEntry = getTextEntryFromInput(el, textKey);
                if (isValidValue(textEntry.value, opts.skipFalsy))
                    saveEntryToResult(result, textEntry, opts.delimiter);
            }
            if (!isInput(el)) continue;
            if (!(key = (el.name || opts.useIdOnEmptyName && el.id))) continue;
            if (nodeCallback) entry = nodeCallback(el, key);
            if (!entry) entry = getEntryFromInput(el, key);
            if (isValidValue(entry.value, opts.skipFalsy))
                saveEntryToResult(result, entry, opts.delimiter);
        }
        return result;
    }

    function isValidValue(value, skipFalsy) {
        return typeof value !== 'undefined' && (!skipFalsy || (value && (!isArray(value) || value.length)))
    }

    function getEntryFromInput(el, key) {
        var nodeType = el.type && el.type.toLowerCase(), value;

        switch (nodeType) {
            case 'radio':
                if (el.checked)
                    value = el.value === 'on' ? true : el.value;
                break;
            case 'checkbox':
                value = el.checked ? (el.value === 'on' ? true : el.value) : false;
                break;
            case 'select-multiple':
                value = [];
                for (var i = 0, l = el.options.length; i < l; i++)
                    if (el.options[i].selected) value.push(el.options[i].value);
                break;
            case 'file':
{'fraction_non_alphanumeric': 0.1333211745394857, 'fraction_numerical': 0.0009119095385737735, 'mean_word_length': 1.932620320855615, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4071679', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1504, 'n_words': 372}