<commit_before>$.doTemplate = (function() {

    // template object constructor
    var t = function doTemplate(config) {

        this.source = config.source;
        this.data = config.data;

        if (this.data) this.compile(config.data);
        else this.compiled = null;
        
        return this;
    };
            
    // add some inherited methods
    $.extend(t.prototype, {

        // compile data using the compiler
        compile: function(data) {
        
            var frag = document.createDocumentFragment(),
                compiler = $.doTemplate.engine(this.source),
                compiled_src, $item,
                add = function(i, object) {
                
                    // get the compiled source string
                    compiled_src = compiler(object);
                    
                    // create a jQuery object
                    $item = $(compiled_src);
                    
                    $item.data('doTemplate', {
                        source: this.source,
                        data: object
                    }).each(function() {
                        frag.appendChild(this);
                    });
                };
                        
            // handle correct data
            data = data || this.data || false;
            if (!data) return this;
            
            // force data into an array if needed
            if (data.constructor == Object) data = [data];
            
            // loop through data and add new item
            $.each(data, add);
            
            // store compiled version as jQuery object (so we can clone it on render)
            this.compiled = $(frag);
            
            return this;
        },

        appendTo: function(selector) {
            return this.render(selector, 'append');
        },
 
        prependTo: function(selector) {
            return this.render(selector, 'prepend');
        },
        
        insertBefore: function(selector) {
            return this.render(selector, 'before');
        },
 
        insertAfter: function(selector) {
            return this.render(selector, 'after');
        },

        replace: function(selector) {
            return this.render(selector, 'replaceWith');
        },<commit_msg>Improved handling of non array object, should improved performance as not invoking $.each<commit_after>$.doTemplate = (function() {

    // template object constructor
    var t = function doTemplate(config) {

        this.source = config.source;
        this.data = config.data;

        if (this.data) this.compile(config.data);
        else this.compiled = null;
        
        return this;
    };
            
    // add some inherited methods
    $.extend(t.prototype, {

        // compile data using the compiler
        compile: function(data) {
        
            var frag = document.createDocumentFragment(),
                compiler = $.doTemplate.engine(this.source),
                compiled_src, $item,
                add = function(i, object) {
                
                    // get the compiled source string
                    compiled_src = compiler(object);
                    
                    // create a jQuery object
                    $item = $(compiled_src);
                    
                    $item.data('doTemplate', {
                        source: this.source,
                        data: object
                    }).each(function() {
                        frag.appendChild(this);
                    });
                };
                        
            // handle correct data
            data = data || this.data || false;
            if (!data) return this;
            
            // force data into an array if needed
            if ($.isArray(data)) $.each(data, add);
            else add(null, data);
            
            // store compiled version as jQuery object (so we can clone it on render)
            this.compiled = $(frag);
            
            return this;
        },

        appendTo: function(selector) {
            return this.render(selector, 'append');
        },
 
        prependTo: function(selector) {
            return this.render(selector, 'prepend');
        },
        
        insertBefore: function(selector) {
            return this.render(selector, 'before');
        },
 
        insertAfter: function(selector) {
            return this.render(selector, 'after');
        },

        replace: function(selector) {
            return this.render(selector, 'replaceWith');
        },
{'fraction_non_alphanumeric': 0.09814612868047982, 'fraction_numerical': 0.0, 'mean_word_length': 1.2165297245045916, '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': '4170673', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1013, 'n_words': 279}