當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore._類代碼示例

本文整理匯總了TypeScript中underscore._的典型用法代碼示例。如果您正苦於以下問題:TypeScript _類的具體用法?TypeScript _怎麽用?TypeScript _使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了_類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: run

    run(parsers:IParser[]){
        if(_.isUndefined(parsers)){
            parsers = [];
        }

        parsers.push(new Haskell.HaskellParser());

        var config = new Config.Config().getConfig();

        var server = new Server.Server(process.env.PORT || config.port, config);

        var watchPaths = [config.projectSource + "/dist/test/"];

        var fileWatcher = new FileWatcher.FileWatcher(watchPaths, path => {
            try{
                for(var i = 0; i< parsers.length; i++){
                    var contents = parsers[i].parseFile(path);

                    server.notifyConnections(contents);

                    console.log((path + " changed").cyan);

                    return;
                }
            }
            catch(e){

            }
        });

        server.start();

        open("http://localhost:" + server.port);
    }
開發者ID:devshorts,項目名稱:htf-viewer,代碼行數:34,代碼來源:app.ts

示例2: function

   value: function(unit: WorldObject, spell, target) {
   if (_.isString(spell)) {
     checkParams('cast', arguments, WorldObject, String, WorldObject);
     attemptSpellcast(state, unit, new SpellTarget(target.id, undefined), spell);
   } else {
     if (target instanceof WorldObject) {
       checkParams('cast', arguments, WorldObject, Spell, WorldObject);
       attemptSpellcast(state, unit, new SpellTarget(target.id, undefined), spell.name);
     } else if (_.isArray(target)) {
       checkParams('cast', arguments, WorldObject, Spell, Array);
       attemptSpellcast(state, unit, new SpellTarget(target.id, undefined), spell.name);
     } else {
       throw new Error('Unknown arguments passed to `cast`');
     }
   }
 }
開發者ID:rmx,項目名稱:encounter,代碼行數:16,代碼來源:Global.ts

示例3: isCompatibleType

function isCompatibleType(value, type, typeName: string): boolean {
    if (type === Function) {
        return _.isFunction(value);

    } else if (type === Object) {
        return _.isObject(value);

    } else if (type === Array) {
        return _.isArray(value);

    } else if (type === String || type === Number || type === Boolean) {
        return type === value.constructor;

    } else {
        return typeName === value.constructor.name;
    }
}
開發者ID:rmx,項目名稱:encounter,代碼行數:17,代碼來源:Env.ts

示例4: getConfig

    getConfig():ConfigData{
        var defaults:ConfigData = {
            projectSource: process.cwd(),
            port: 3000
        };

        var config = defaults;

        var overrideConfigPath = process.cwd() + "/hconfig.json";

        if(fs.existsSync(overrideConfigPath)){
            console.log(("found config path @ " + overrideConfigPath).yellow);

            config = _.defaults(JSON.parse(fs.readFileSync(overrideConfigPath).toString()), defaults);
        }
        else{
            console.log("using default config".yellow);
        }

        console.log(("Source Dir: " + config.projectSource).green);
        console.log(("Port: " + config.port).green);

        return config;
    }
開發者ID:devshorts,項目名稱:htf-viewer,代碼行數:24,代碼來源:config.ts

示例5:

 var result = underscore._.find(values,function(value:T){underscore._.isEqual(obj , value)})
開發者ID:Villaz,項目名稱:Icarus,代碼行數:1,代碼來源:map.ts

示例6: getTexture

 getTexture(name: string): Texture {
     return _.find(this.textures, texture => {
         return texture.type == name;
     });
 }
開發者ID:rmx,項目名稱:encounter,代碼行數:5,代碼來源:Skybox.ts


注:本文中的underscore._類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。