本文整理汇总了TypeScript中async.parallel函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parallel函数的具体用法?TypeScript parallel怎么用?TypeScript parallel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parallel函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: calculateFor2
function calculateFor2(tier:Tier, attack:ActionType, nonRandom:boolean, done: any){
var i = 0;
while(i < neededInstances){
let boundDo = doMoveInLoop2.bind(null, tier, attack, nonRandom);
callsToMake.push(boundDo);
i++;
}
async.parallel(callsToMake, function(err, res){
let turnsData = res.map((x) => x[0]);
let hpData = [].concat.apply([], res.map((x) => x[1]));
let lpData = [].concat.apply([], res.map((x) => x[2]));
let fpData = [].concat.apply([], res.map((x) => x[3]));
console.log(`${(nonRandom ? "1":"0")};${Tier[tier]};${ActionType[attack]};${stats.mean(turnsData)};${stats.median(turnsData)};${stats.variance(turnsData)};${stats.stdev(turnsData)};${stats.percentile(turnsData, 0.90)};${stats.mean(hpData)};${stats.median(hpData)};${stats.variance(hpData)};${stats.stdev(hpData)};${stats.percentile(hpData, 0.90)};${stats.mean(lpData)};${stats.median(lpData)};${stats.variance(lpData)};${stats.stdev(lpData)};${stats.percentile(lpData, 0.90)};${stats.mean(fpData)};${stats.median(fpData)};${stats.variance(fpData)};${stats.stdev(fpData)};${stats.percentile(fpData, 0.90)}`);
res = null;
turnsData = null;
hpData = null;
lpData = null;
fpData = null;
if(done != null){
done();
}
callsToMake = null;
});
}
开发者ID:AelithBlanchett,项目名称:nsfwbot,代码行数:26,代码来源:stats.ts
示例2: function
Collections.Tips.findOne({"recipient.id": chatterID, "unregisteredUser": true}, function(err: Error, tip: any) {
if (err) {
bot.sendMessage(chatterID, reportError(err, "Retrieving tip in +accept"));
return;
}
if (!tip) {
bot.sendMessage(chatterID, "There are no pending tips involving you");
return;
}
async.parallel([
function(callback) {
Collections.Tips.update({"_id": tip["_id"]}, {$set: {accepted: true}}, {multi: true}, callback);
},
function(callback) {
// Delete the autoregistered attribute because that user is now fully registered
Collections.Users.update({"id": chatterID}, {$unset: {"autoregistered": ""}}, callback);
}
], function(err: Error) {
if (err) {
bot.sendMessage(chatterID, reportError(err, "async.parallel in +accept"));
}
bot.sendMessage(chatterID, "Congrats, your tip of " + tip.amount + " Gamerscoins from " + tip.sender.name + " was accepted! Welcome to Gamerscoin next generation Trade community");
bot.sendMessage(chatterID, "You can open up the group chat and double click on my name in the sidebar (with the gold star) to send me commands in the future.");
bot.sendMessage(chatterID, "Send '+help' to see all of the available commands.");
bot.sendMessage(chatterID, "If you have any questions or suggestions, please start a discussion within the group. RazeTheRoof <[email protected]> is this bot's author so send any hate/love mail his way.");
});
});
开发者ID:hilmysyarif,项目名称:GamersSteamTipBot,代码行数:27,代码来源:bot.ts
示例3: load
private static load(apis, language, callback) {
var mylib = new api.Lib;
mylib.build(apis);
async.parallel([
(cb) => {
mylib.installIfMissing((err) => {
if(err) {
console.log('Error while installing npm packages.');
console.log(err);
}
cb(); // Don't show error.
});
},
(cb) => {
Language.factory(language, cb);
},
], (err, res) => {
try {
process.nextTick(() => { callback(err, res); });
} catch(e) {
console.log(e);
console.log(e.stack);
}
});
return mylib;
}
开发者ID:streamich,项目名称:jssh,代码行数:26,代码来源:builder.ts
示例4: async
return new Promise<[Array<Devices.Device>, Array<Robots.Robot>, Array<Groups.Group>]>( (resolve, _) => {
Async.parallel({
devices: async (cb) => {
Devices.devicesAsync(authTokens).then((devices) => {
Logger.Log.Info(`obtained ${devices.length} devices...`);
devicesLookup = devices;
cb(null, devices);
});
},
robots: async (cb) => {
Robots.robotsAsync(authTokens).then((robots) => {
Logger.Log.Info(`obtained ${robots.length} robots...`);
robotsLookup = robots;
cb(null, robots);
});
},
groups: async (cb) => {
Groups.groupsAsync(authTokens).then((groups) => {
Logger.Log.Info(`obtained ${groups.length} groups...`);
groupsLookup = groups;
cb(null, groups);
});
}
}, (err, results) => {
// this is to satsify ts' typing checks
const
devices : Array<Devices.Device> = results["devices"],
robots : Array<Robots.Robot> = results["robots"],
groups : Array<Groups.Group> = results["groups"];
resolve([devices, robots, groups]);
});
});
开发者ID:landonbass,项目名称:winky,代码行数:32,代码来源:ui.ts
示例5: getPrices
function getPrices(): void {
async.parallel([
function(callback) {
// Coinbase BTC/USD price
getHTTPPage("https://coinbase.com/api/v1/currencies/exchange_rates", callback);
},
function(callback) {
// Mintpal DOGE/BTC price
getHTTPPage("https://api.mintpal.com/v1/market/stats/DOGE/BTC", callback);
}
], function(err: Error, results: any[]): void {
if (err) {
console.trace(err);
return;
}
try {
prices["BTC/USD"] = parseFloat(JSON.parse(results[0])["btc_to_usd"]);
prices["DOGE/BTC"] = parseFloat(JSON.parse(results[1])[0].last_price);
}
catch(e) {
return;
}
prices["DOGE/USD"] = prices["BTC/USD"] * prices["DOGE/BTC"];
// Return to strings with .toFixed(8)
prices.LastUpdated = Date.now();
});
}
开发者ID:hilmysyarif,项目名称:GamersSteamTipBot,代码行数:27,代码来源:tf2logparser.ts
示例6: compare
export function compare(leftPath: string,
rightPath: string,
callback: CompareCallback): void {
async.parallel<FSNode>({
// atom shell incorrectly wraps fs.lstat, so we need to check for null here, first
leftNode: callback => leftPath ? readCached(leftPath, callback) : setImmediate(callback),
rightNode: callback => rightPath ? readCached(rightPath, callback) : setImmediate(callback),
}, (error, {leftNode, rightNode}) => {
if (error) return callback(error);
if (leftNode && rightNode) {
if (leftNode.type == 'directory' && rightNode.type == 'directory') {
return compareDirectories(Object.assign(leftNode, {path: leftPath}), Object.assign(rightNode, {path: rightPath}), callback);
}
else if (leftNode.type == 'file' && rightNode.type == 'file') {
if (leftNode.size === rightNode.size) {
return callback(null, {left: leftNode, right: rightNode, equal: true});
}
}
return callback(null, {left: leftNode, right: rightNode, equal: false});
}
else if (leftNode) {
return callback(null, {left: leftNode, right: null, equal: false});
}
else { // if (rightNode) {
return callback(null, {left: null, right: rightNode, equal: false});
}
});
}
开发者ID:chbrown,项目名称:fs-ui,代码行数:28,代码来源:fs-helpers.ts
示例7: done
return new Promise<any>((resolve)=>{
async.parallel({
count:function (done) {// 查询数量
MongoModel.count(queryParams).exec(function (err,count) {
done(err,count);
});
},
records:function (done) {
MongoModel.find(queryParams,fileds).skip(start).limit(pageSize).populate(populate).sort(sortParams).exec(function (err, doc) {
done(err, doc);
});
}
},function (err, results) {
var count = results.count;
$page.pageCount = (count - 1) / pageSize + 1;
$page.results = results.records;
$page.Total=count;
if(!err){
resolve($page);
}
else {
resolve(err);
}
})
})
开发者ID:guoyu07,项目名称:react-node-cms,代码行数:26,代码来源:pageQueryHelper.ts
示例8: cleanAll
function cleanAll(done) {
async.parallel([
cleanDist,
cleanTest,
cleanTmp
], done);
}
开发者ID:adamayres,项目名称:peeps2,代码行数:7,代码来源:clean.ts
示例9: kongGetAllApis
export function kongGetAllApis(callback: Callback<KongCollection<KongApi>>): void {
debug('kongGetAllApis()');
async.parallel({
services: callback => kongGetAllServices(callback),
routes: callback => kongGetAllRoutes(callback)
}, function (err, results) {
if (err)
return callback(err);
const services = results.services as KongCollection<KongService>;
const routes = results.routes as KongCollection<KongRoute>;
// Step 1: Build a service id to service map
const serviceIdMap = new Map<string, KongService>();
for (let i = 0; i < services.data.length; ++i) {
const s = services.data[i];
serviceIdMap.set(s.id, s);
}
// Step 2: Match the routes to the services
const kongApis: KongApi[] = [];
for (let i = 0; i < routes.data.length; ++i) {
const r = routes.data[i];
if (!serviceIdMap.has(r.service.id)) {
warn(`kongGetAllApis: Route ${r.id} with paths ${r.paths} has an unknown service id ${r.service.id}`);
continue;
}
kongApis.push(wicked.kongServiceRouteToApi(serviceIdMap.get(r.service.id), r));
}
return callback(null, {
data: kongApis
});
});
// kongGet('apis?size=1000000', callback);
}
开发者ID:Haufe-Lexware,项目名称:wicked.portal-kong-adapter,代码行数:34,代码来源:utils.ts
示例10: getPrices
function getPrices(): void {
async.parallel([
function(callback) {
// Coinbase BTC/USD price
getHTTPPage("https://coinbase.com/api/v1/currencies/exchange_rates", callback);
},
function(callback) {
// Mintpal GMC/BTC price
getHTTPPage("https://api.comkort.com/v1/public/market/summary?market_alias=gmc_btc", callback);
}
], function(err: Error, results: any[]): void {
if (err) {
reportError(err, "Getting current prices");
return;
}
try {
prices["BTC/USD"] = parseFloat(JSON.parse(results[0])["btc_to_usd"]);
prices["GMC/BTC"] = parseFloat(JSON.parse(results[1]).markets["GMC/BTC"].last_price);
}
catch(e) {
return;
}
prices["GMC/USD"] = prices["BTC/USD"] * prices["GMC/BTC"];
// Return to strings with .toFixed(8)
prices.LastUpdated = Date.now();
});
}
开发者ID:hilmysyarif,项目名称:GamersSteamTipBot,代码行数:27,代码来源:bot.ts
注:本文中的async.parallel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论