具有自动放样功能的JavaScript美化器/格式化程序

具有自动放样功能的JavaScript美化器/格式化程序,javascript,code-formatting,Javascript,Code Formatting,我一直在寻找一个代码美化器/格式化程序,它将为我做变量和函数放样。在我写的时候,我可能有一个特别长的函数,而不是向上移动到顶部来放样变量和函数,我将在我所在的位置添加它们。然后我继续,忘记了放样新的变量和函数 我希望它能做这样的事情 // ugly code function myFunction(){ //... 50 lines of code ... for(var i = 0; i < 100; i++){ //... code ... }

我一直在寻找一个代码美化器/格式化程序,它将为我做变量和函数放样。在我写的时候,我可能有一个特别长的函数,而不是向上移动到顶部来放样变量和函数,我将在我所在的位置添加它们。然后我继续,忘记了放样新的变量和函数

我希望它能做这样的事情

// ugly code
function myFunction(){
    //... 50 lines of code ...
    for(var i = 0; i < 100; i++){
        //... code ...
    }
    //... much more code and return some weeks later to add...
    for(var i = 0; i < 100; i++){  // cant remember if I have an i declared
                                   // so to be safe add the var token
        //... code ...
    }
    var blah = {};
    var arr = [blah,blah,blah];   // I am just to lazy to loft it while coding
    var iteratorFunction = function(item){    
        //... Building code as I write the dependent parts  so don't ...
        //... want to go up to the top all the time ...
    }
    arr.forEach(iteratorFunction);

}
//丑陋的代码
函数myFunction(){
//…50行代码。。。
对于(变量i=0;i<100;i++){
//…代码。。。
}
//…更多代码,几周后返回以添加。。。
对于(var i=0;i<100;i++){//我记不起是否有一个i声明的
//为了安全起见,添加var标记
//…代码。。。
}
var blah={};
var arr=[blah,blah,blah];//我只是懒得在编码时对其进行放样
var iteratorFunction=函数(项){
//…当我编写相关部分时生成代码,所以不要。。。
//…想一直登上顶峰。。。
}
arr.forEach(迭代器函数);
}
应该被美化成

// beautiful code, well close enough
function myFunction() {
    var i, arr, blah;
    var iteratorFunction = function(item) {   
        //... code ...
    }
    //... 50 lines of code ...
    for(i = 0; i < 100; i++) {  // the var token has been removed
        //... code ...
    }
    //... more code ...
    for(i = 0; i < 100; i++){  //  the var token has been removed
        //... code ...
    }

    blah = {};                    // var token removed
    arr = [blah, blah, blah];     // var token removed
    // function lofted
    arr.forEach(iteratorFunction);
}
//代码很漂亮,足够近了
函数myFunction(){
变量i,arr,blah;
var iteratorFunction=函数(项){
//…代码。。。
}
//…50行代码。。。
对于(i=0;i<100;i++){//已删除var标记
//…代码。。。
}
//…更多代码。。。
对于(i=0;i<100;i++){//已删除var标记
//…代码。。。
}
blah={};//var标记已删除
arr=[blah,blah,blah];//已删除var标记
//函数放样
arr.forEach(迭代器函数);
}

我自己还没有试过,但听起来好像它能满足你的需求:提升功能和提升变量谢谢,只要阅读文档,就可以了。更好的是javascript,因为我应该能够将它与基于ace的IDE集成。不客气,希望这是您想要的。懒得亲自测试:)“放样”是指在放样中进行的工作,通常是指需要一个大而平坦的空间,且没有任何结构(例如为船体框架或帆设置大的曲线)。该术语也适用于此类工作,即使不是在阁楼中实际完成。不确定该术语是否适用于将某物搬进阁楼(隐喻或物理)。在这方面,“提升”可能是一个更好的术语(尽管我不喜欢它)