<commit_before>/*
    by liz
*/

;(function(exports, undefined){

var zita = exports.zita = {
    version : 0.0.1
};


// array or object

var slice = function(arr, start, end){
    return Array.prototype.slice.call(arr, start, end);
}

zita.each = function(obj, callback){
    var keys,
        i = 0;

    if(obj == null) return;

    if(obj.forEach){
        obj.forEach(function(){
            return callback.apply(zita, arguments);
        })

        return;
    }

    if(obj.length){
        // if obj is array
        for(; i < obj.length; i++){
            if(callback.call(zita, i, obj[i], obj) === false) break;
        }
    }else{
        // if obj is object
        keys = zita.keys(obj);
        for(; i < keys.length; i++){
            if(callback.call(zita, keys[i], obj[keys[i]], obj) === false) break;
        }
    }

    return;
}

zita.merge = function(dest, orig){
    var res = slice(dest, 1),
        offset = res.length,
        i = 0;

    for(; i < res.length; i++){
        res[offset + i] = orig[i];
    }

    return res;
}

var IS_DONTENUM_BUG = (function(){
    for(var prop in {toString : 1}){
        if(prop == 'toString') return false;
    }
    return true;
})();

zita.keys = function(obj){
    var res = [],
        prop;
    
    for(prop in obj){
        if(!obj.hasOwnProperty(prop)) continue;
        res.push(prop);
    }

    // fix don't enum bug
    if(IS_DONTENUM_BUG){
        if(obj.toString !== Object.prototype.toString){
            res.push('toString');
        }

        if(obj.valueOf !== Object.prototype.valueOf){
            res.push('valueOf');
        }
    }

    return res;
}

zita.values = function(obj){
    var res = [];
        prop;

    for(prop in obj){
        if(!obj.hasOwnProperty(prop)) continue;
        res.push(obj[prop]);
    }

    // fix don't enum bug
    if(IS_DONTENUM_BUG){
        if(obj.toString !== Object.prototype.toString){
            res.push(obj.toString);
        }

        if(obj.valueOf !== Object.prototype.valueOf){
            res.push(obj.valueOf);
        }
    }

    return res;
}

zita.extend = function(dest, orig){
    var keys = zita.keys(orig),
        i = 0;

    for(; i < keys.length; i++){
        dest[keys[i]] = orig[keys[i]];
    });

    return dest;
}

zita.clone = function(orig){
    return zita.extend({}, orig);
}


// function

var now = Date.now || function(){
    return (new Date).getTime();
}

zita.debounce = function(callback, delay){
    var timer = null;

    function clear(){
        clearTimeout(timer);
        timer = null;
    }

    delay = delay || 200;

    return function(){
        var orig = callback,
            context = this,
            args = arguments;

        callback = function(){
            clear();
            orig.apply(context, args);
        }

        timer && clear();
        timer = setTimeout(callback, delay);
    }
}

zita.pulse = function(callback, period, delay){
    var timer = null,
        endtime, active;

    function clear(){
        clearInterval(timer);
        timer = null;
        active = false;
    }

    delay = delay || 200;
    period = period || 1000;

    return function(){
        var orig = callback,
            context = this,
            args = arguments;

        callback = function(){
            orig.apply(context, args);
            if(now() > endtime){
                clear();
            }
        }

        endtime = now() + period;
        if(!active){
            active = true;
            timer = setInterval(callback, delay);
        }
    }
}


// dom and cssom

zita.Node = (function(){

    var win = window,
        doc = document,
        docRoot = doc.documentElement,
        body = doc.body;

    function getElementNode(node){
        if(node && node.nodeType){
            if(node.nodeType == 3){
                node = node.parentNode;
            }

            return node;
        }

        if(node && node.zita){
            return node.self;
        }

        return false
    }

    function Node(node){
        if(node.length){
            node = node[0];
        }

        if(!(node = getElementNode(node))){
            throw Error('not element node');
        }
<commit_msg>add function max and min<commit_after>/*
    by liz
*/

;(function(exports, undefined){

var zita = exports.zita = {
    version : 0.0.1
};


// array or object

var slice = function(arr, start, end){
    return Array.prototype.slice.call(arr, start, end);
}

var IS_DONTENUM_BUG = (function(){
    for(var prop in {toString : 1}){
        if(prop == 'toString') return false;
    }
    return true;
})();

zita.keys = function(obj){
    var res = [],
        prop;
    
    for(prop in obj){
        if(!obj.hasOwnProperty(prop)) continue;
        res.push(prop);
    }

    // fix don't enum bug
    if(IS_DONTENUM_BUG){
        if(obj.toString !== Object.prototype.toString){
            res.push('toString');
        }

        if(obj.valueOf !== Object.prototype.valueOf){
            res.push('valueOf');
        }
    }

    return res;
}

zita.values = function(obj){
    var res = [];
        prop;

    for(prop in obj){
        if(!obj.hasOwnProperty(prop)) continue;
        res.push(obj[prop]);
    }

    // fix don't enum bug
    if(IS_DONTENUM_BUG){
        if(obj.toString !== Object.prototype.toString){
            res.push(obj.toString);
        }

        if(obj.valueOf !== Object.prototype.valueOf){
            res.push(obj.valueOf);
        }
    }

    return res;
}

var each = zita.each = function(obj, callback){
    var keys,
        i = 0;

    if(obj == null) return;

    if(obj.forEach){
        obj.forEach(function(){
            return callback.apply(zita, arguments);
        })

        return;
    }

    if(obj.length){
        // if obj is array
        for(; i < obj.length; i++){
            if(callback.call(zita, i, obj[i], obj) === false) break;
        }
    }else{
        // if obj is object
        keys = zita.keys(obj);
        for(; i < keys.length; i++){
            if(callback.call(zita, keys[i], obj[keys[i]], obj) === false) break;
        }
    }

    return;
}

zita.merge = function(dest, orig){
    var res = slice(dest, 1),
        offset = res.length,
        i = 0;

    for(; i < res.length; i++){
        res[offset + i] = orig[i];
    }

    return res;
}

zita.extend = function(dest, orig){
    var keys = zita.keys(orig),
        i = 0;

    for(; i < keys.length; i++){
        dest[keys[i]] = orig[keys[i]];
    });

    return dest;
}

zita.clone = function(orig){
    return zita.extend({}, orig);
}

zita.max = function(arr, iterator){
    var proxy, max,
        i = 0;

    max = {proxy : -Infinity, value : -Infinity};
    for(; i < arr.length; i++){
        proxy = iterator ? iterator.call(zita, arr[i], i) : arr[i];
        if(proxy > max.proxy){
            max.proxy = proxy;
            max.value = arr[i];
        }
    }

    return max.value;
}

zita.min = function(arr, iterator){
    var proxy, min,
        i = 0;

    min = {proxy : -Infinity, value : -Infinity};
    for(; i < arr.length; i++){
        proxy = iterator ? iterator.call(zita, arr[i], i) : arr[i];
        if(proxy < min.proxy){
            min.proxy = proxy;
            min.value = arr[i];
        }
    }

    return min.value;
}


// function

var now = Date.now || function(){
    return (new Date).getTime();
}

zita.debounce = function(callback, delay){
    var timer = null;

    function clear(){
        clearTimeout(timer);
        timer = null;
    }

    delay = delay || 200;

    return function(){
        var orig = callback,
            context = this,
            args = arguments;

        callback = function(){
            clear();
            orig.apply(context, args);
        }

        timer && clear();
        timer = setTimeout(callback, delay);
    }
}

zita.pulse = function(callback, period, delay){
    var timer = null,
        endtime, active;

    function clear(){
        clearInterval(timer);
        timer = null;
        active = false;
    }

    delay = delay || 200;
    period = period || 1000;

    return function(){
        var orig = callback,
            context = this,
            args = arguments;

        callback = function(){
            orig.apply(context, args);
            if(now() > endtime){
                clear();
            }
        }

        endtime = now() + period;
        if(!active){
            active = true;
            timer = setInterval(callback, delay);
        }
    }
}


// dom and cssom

zita.Node = (function(){

    var win = exports,
        doc = win.document,
        docRoot = doc.documentElement,
        body = doc.body;

    function getElementNode(node){
        if(node && node.nodeType){
            if(node.nodeType == 3){
                node = node.parentNode;
            }

            return node;
        }

        if(node && node.zita){
            return node.self;
        }

        return false
    }

    function Node(node){
        if(node.length){
            node = node[0];
        }

        if(!(node = getElementNode(node))){
            throw Error('not element node');
        }

{'fraction_non_alphanumeric': 0.1455496241420634, 'fraction_numerical': 0.004575661836801395, 'mean_word_length': 1.6554816314723748, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 6, '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': '1574044', 'n_tokens_mistral': 2938, 'n_tokens_neox': 2825, 'n_words': 674}