本文整理匯總了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;
});
}