<commit_before>(function (root) {

    'use strict';

    var nano = function (selector) {

        if (!(this instanceof nano)) {
            return new nano(selector);
        }

        if (selector instanceof nano) {
            return selector;
        }

        if (selector instanceof HTMLElement || selector instanceof NodeList) {
            this.nodes = (selector.length > 1) ? [].slice.call(selector) : [selector];
        } else if (typeof selector === 'string') {         
            if (new RegExp(/^</).test(selector)) {
                this.nodes = [nano.createNode(selector)];
            } else if (new RegExp(/^\#[\w\-]+$/).test(selector)) {
                return document.getElementById(selector);
            } else if (new RegExp(/^\.[\w\-]+$/).test(selector)) {
                this.nodes = document.getElementsByClassName(selector.substr(1));  
            } else if (new RegExp(/^\w+$/).test(selector)) {
                this.nodes = [].slice.call(document.getElementsByTagName(selector));
            } else {
                this.nodes = [].slice.call(document.querySelectorAll(selector));
            }
        }

        if (this.nodes.length) {
            this.length = this.nodes.length;
            for (var i = 0; i < this.nodes.length; i++) {
                this[i] = this.nodes[i];
            }
        }

        return this;

    }

    nano.prototype = {

        /**
         * Extends nano.each()
         */
        each: function (callback) {
            nano.each(this, callback);
        },

        /**
         * Return first element in array
         */
        first: function () {
            return nano(this[0]);
        },

        /**
         * Return last element in array
         */
        last: function () {
            return nano(this[this.length - 1]);
        },

        /**
         * Check if element has class
         */
        hasClass: function (className) {
            if (document.documentElement.classList) {
                return this[0].classList.contains(className);
            } else {
                return new RegExp('(^|\\s)' + className + '(\\s|$)').test(this[0].className);
            }
        },

        /**
         * Add class to element
         */
        addClass: function (className) {
            if (!this.hasClass(className)) {
                if (document.documentElement.classList) {
                    return this.each(function () {
                        this.classList.add(className);
                    });
                } else {
                    return this.each(function () {
                        this.className += ' ' + className;
                    });
                }
            }
        },

        /**
         * Remove class from element
         */
        removeClass: function (className) {
            if (this.hasClass(className)) {
                if (document.documentElement.classList) {
                    return this.each(function () {
                        this.classList.remove(className);
                    });
                } else {
                    return this.each(function () {
                        this.className = this.className.replace(new RegExp('(^|\\s)*' + className + '(\\s|$)*', 'g'), '');
                    });
                }
            }
        },

        /**
         * Toggle class on element
         */
        toggleClass: function (className) {
            if (document.documentElement.classList) {
                return this.each(function () {
                    this.classList.toggle(className);
                });
            } else {
                return this.each(function () {
                    if (this.hasClass(className)) {
                        this.removeClass(className);
                    } else {
                        this.addClass(className);
                    }
                });
            }
        },

        /**
         * Add event
         */
        on: function (type, callback) {
            if (document.addEventListener) {
                return this.each(function () {
                    this.addEventListener(type, callback, false);
                });
            } else if (document.attachEvent) {
                return this.each(function () {
                    this.attachEvent('on' + type, callback);
                });
            }
        },

        /**
         * Remove event
         */
        off: function () {
            if (document.removeEventListener) {
                return this.each(function () {
                    this.removeEventListener(type, callback, false);
                });
            } else if (document.detachEvent) {
                return this.each(function () {
                    this.detachEvent('on' + type, callback);
                });
            }
        },

        /**
         * Determine if an element is in viewport
         */
        inview: function () {
            var distance = this[0].getBoundingClientRect();
            if (distance.top <= (window.innerHeight || document.documentElement.clientHeight) && distance.bottom >= 0) {
                return true;
            } else {
                return false;
            }
        }
    }

    /**
     * Create a new node for DOM
     */
    nano.createNode = function (html) {
        var div = document.createElement('div');
        div.innerHTML = html;
        return div.firstChild;
    }

    /**
     * Loop through a collection and calls the callback method on each
     */
    nano.each = function (collection, callback) {
        for (var i = 0; i < collection.length; i++) {
            callback.call(collection[i], collection, i);
        }
    };

    /**
     * Wait until the DOM is ready before executing code
     */
    nano.ready = function (callback) {
        if (typeof callback !== 'function') {
            return;
        }
        if (document.readyState === 'complete') {
            return callback();
        }
        document.addEventListener('DOMContentLoaded', callback, false);
    }

    root.nano = root.$ = root.n = nano;

})(this);
<commit_msg>add substr to id selector<commit_after>(function (root) {

    'use strict';

    var nano = function (selector) {

        if (!(this instanceof nano)) {
            return new nano(selector);
        }

        if (selector instanceof nano) {
            return selector;
        }

        if (selector instanceof HTMLElement || selector instanceof NodeList) {
            this.nodes = (selector.length > 1) ? [].slice.call(selector) : [selector];
        } else if (typeof selector === 'string') {         
            if (new RegExp(/^</).test(selector)) {
                this.nodes = [nano.createNode(selector)];
            } else if (new RegExp(/^\#[\w\-]+$/).test(selector)) {
                console.log('id');
                return document.getElementById(selector.substr(1));
            } else if (new RegExp(/^\.[\w\-]+$/).test(selector)) {
                this.nodes = document.getElementsByClassName(selector.substr(1));  
            } else if (new RegExp(/^\w+$/).test(selector)) {
                this.nodes = [].slice.call(document.getElementsByTagName(selector));
            } else {
                this.nodes = [].slice.call(document.querySelectorAll(selector));
            }
        }

        if (this.nodes.length) {
            this.length = this.nodes.length;
            for (var i = 0; i < this.nodes.length; i++) {
                this[i] = this.nodes[i];
            }
        }

        return this;

    }

    nano.prototype = {

        /**
         * Extends nano.each()
         */
        each: function (callback) {
            nano.each(this, callback);
        },

        /**
         * Return first element in array
         */
        first: function () {
            return nano(this[0]);
        },

        /**
         * Return last element in array
         */
        last: function () {
            return nano(this[this.length - 1]);
        },

        /**
         * Check if element has class
         */
        hasClass: function (className) {
            if (document.documentElement.classList) {
                return this[0].classList.contains(className);
            } else {
                return new RegExp('(^|\\s)' + className + '(\\s|$)').test(this[0].className);
            }
        },

        /**
         * Add class to element
         */
        addClass: function (className) {
            if (!this.hasClass(className)) {
                if (document.documentElement.classList) {
                    return this.each(function () {
                        this.classList.add(className);
                    });
                } else {
                    return this.each(function () {
                        this.className += ' ' + className;
                    });
                }
            }
        },

        /**
         * Remove class from element
         */
        removeClass: function (className) {
            if (this.hasClass(className)) {
                if (document.documentElement.classList) {
                    return this.each(function () {
                        this.classList.remove(className);
                    });
                } else {
                    return this.each(function () {
                        this.className = this.className.replace(new RegExp('(^|\\s)*' + className + '(\\s|$)*', 'g'), '');
                    });
                }
            }
        },

        /**
         * Toggle class on element
         */
        toggleClass: function (className) {
            if (document.documentElement.classList) {
                return this.each(function () {
                    this.classList.toggle(className);
                });
            } else {
                return this.each(function () {
                    if (this.hasClass(className)) {
                        this.removeClass(className);
                    } else {
                        this.addClass(className);
                    }
                });
            }
        },

        /**
         * Add event
         */
        on: function (type, callback) {
            if (document.addEventListener) {
                return this.each(function () {
                    this.addEventListener(type, callback, false);
                });
            } else if (document.attachEvent) {
                return this.each(function () {
                    this.attachEvent('on' + type, callback);
                });
            }
        },

        /**
         * Remove event
         */
        off: function () {
            if (document.removeEventListener) {
                return this.each(function () {
                    this.removeEventListener(type, callback, false);
                });
            } else if (document.detachEvent) {
                return this.each(function () {
                    this.detachEvent('on' + type, callback);
                });
            }
        },

        /**
         * Determine if an element is in viewport
         */
        inview: function () {
            var distance = this[0].getBoundingClientRect();
            if (distance.top <= (window.innerHeight || document.documentElement.clientHeight) && distance.bottom >= 0) {
                return true;
            } else {
                return false;
            }
        }
    }

    /**
     * Create a new node for DOM
     */
    nano.createNode = function (html) {
        var div = document.createElement('div');
        div.innerHTML = html;
        return div.firstChild;
    }

    /**
     * Loop through a collection and calls the callback method on each
     */
    nano.each = function (collection, callback) {
        for (var i = 0; i < collection.length; i++) {
            callback.call(collection[i], collection, i);
        }
    };

    /**
     * Wait until the DOM is ready before executing code
     */
    nano.ready = function (callback) {
        if (typeof callback !== 'function') {
            return;
        }
        if (document.readyState === 'complete') {
            return callback();
        }
        document.addEventListener('DOMContentLoaded', callback, false);
    }

    root.nano = root.$ = root.n = nano;

})(this);

{'fraction_non_alphanumeric': 0.1270754029318863, 'fraction_numerical': 0.0017008180124726655, 'mean_word_length': 1.2288808664259927, 'pattern_counts': {'":': 0, '<': 11, '<?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': '5745724', 'n_tokens_mistral': 3154, 'n_tokens_neox': 2982, 'n_words': 645}