<commit_before>angular
    .module("fileOpera",[])
    .factory("fileUpdate",[function(){
        var devtools = chrome.devtools;
        var port = chrome.extension.connect(),
            devtoolsConsole = function(content){
                devtools.inspectedWindow.eval("console.log('"+JSON.stringify(content)+"')");
            },
            //need escape char
            reg = /[\*|\.|\?|\+|\$|\^|\[|\]|\(|\)|\{|\}|\||\\|\/]/g,
            //trim and get \n,\s
            reg1 = /^(\s*\n?)(\t*\s*)(\S+)\s*\n$/,
            trim = function(str){
                return str.replace(reg1,"$3");
            },
            lastCon;
            devtoolsConsole(1);
            
        return function(context){
                //listen resourceContentCommitted,and format code
                devtools.inspectedWindow.onResourceContentCommitted.addListener(function(resource,content){
                    var matchReg = [],
                        newContent,
                        compareCon = content;
                    
                    if(lastCon === compareCon){
                        return;
                    }else{
                        lastCon = compareCon;
                    }
                    
                    for(var k in context.formatMap){
                        matchReg.push(k.replace(reg,function(n){return "\\"+n;}));
                    }
                    matchReg = new RegExp("\\n?\\s*("+matchReg.join("|")+")\\s*\\n","g");
        
                    if(matchReg.test(content)){
                        newContent = content.replace(matchReg,function(n){
                            var list = reg1.exec(n);
                            devtoolsConsole(list);
                            return ((list[1]+context.formatMap[trim(n)]).replace(/\n/g,"\n"+list[2])+"\n")||n;
                        });
                        resource.setContent(newContent,false,function(err){
                            if(err)
                                devtoolsConsole(err);
                        });
                        devtools.inspectedWindow.getResources(function(resources){
                            devtoolsConsole(resources);
                        });
                    }
                });
                
                port.postMessage({
                    scriptToInject: 'js/content.js',
                    tabId: devtools.inspectedWindow.tabId
                });
        }
    }]);<commit_msg>Update fileUpdate.js<commit_after>angular
    .module("fileOpera",["fileIO"])
    .factory("fileUpdate",["io",function(io){
        var devtools = chrome.devtools;
        var port = chrome.extension.connect(),
            devtoolsConsole = function(content){
                devtools.inspectedWindow.eval("console.dir("+JSON.stringify(content)+")");
            },
            //need escape char
            reg = /[\*|\.|\?|\+|\$|\^|\[|\]|\(|\)|\{|\}|\||\\|\/]/g,
            //trim and get \n,\x20,\t
            reg1 = /^(\n?)(\t*\x20*)(\S+)\s*\n$/,
            trim = function(str){
                return str.replace(reg1,"$3");
            },
            lastCon;
            
            io();
            
        return function(context){
                //listen resourceContentCommitted,and format code
                devtools.inspectedWindow.onResourceContentCommitted.addListener(function(resource,content){
                    var matchReg = [],
                        newContent,
                        compareCon = content;
                    
                    if(lastCon === compareCon){
                        return;
                    }else{
                        lastCon = compareCon;
                    }
                    
                    for(var k in context.formatMap){
                        matchReg.push(k.replace(reg,function(n){return "\\"+n;}));
                    }
                    
                    //generate regexp
                    matchReg = new RegExp("\\n?[\\t|\\x20]*("+matchReg.join("|")+")\\s*\\n","g");
        
                    if(matchReg.test(content)){
                        newContent = content.replace(matchReg,function(n){
                            var list = reg1.exec(n);
                            devtoolsConsole(list);
                            return ((list[1]+context.formatMap[trim(n)]).replace(/\n/g,"\n"+list[2])+"\n")||n;
                        });
                        devtoolsConsole(newContent);
                        resource.setContent(newContent,false,function(info){
                            if(info.isError){
                                devtoolsConsole(nativeIO.saveBlobToFile);
                                nativeIO.saveBlobToFile(details[0], content);
                            }
                            devtoolsConsole(info);
                        });
                    }
                });
                
               /* devtools.inspectedWindow.onResourceAdded.addListener(function(){
                    devtoolsConsole("fire resourceAdded");
                });
                */
                port.postMessage({
                    scriptToInject: 'js/content.js',
                    tabId: devtools.inspectedWindow.tabId
                });
        }
    }]);
{'fraction_non_alphanumeric': 0.13890468068978587, 'fraction_numerical': 0.0037900322152738296, 'mean_word_length': 1.0536964980544747, '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': '4607481', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1244, 'n_words': 158}