本文整理汇总了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);
}
示例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`');
}
}
}
示例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;
}
}
示例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;
}
示例5:
var result = underscore._.find(values,function(value:T){underscore._.isEqual(obj , value)})
示例6: getTexture
getTexture(name: string): Texture {
return _.find(this.textures, texture => {
return texture.type == name;
});
}