当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript async.each函数代码示例

本文整理汇总了TypeScript中async.each函数的典型用法代码示例。如果您正苦于以下问题:TypeScript each函数的具体用法?TypeScript each怎么用?TypeScript each使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了each函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

	Collections.Tips.find({unregisteredUser: true, accepted: false, refunded: false}).toArray(function(err: Error, unregisteredUserTips: any[]) {
		async.each(unregisteredUserTips, function(tip, callback) {
			var tipTime = tip["_id"].getTimestamp().valueOf();
			var currentTime = Date.now();
			if ((currentTime - tipTime) > (60 * 60 * purgeTime * 1000)) { // x hours in milliseconds
				// Remove friend
				bot.removeFriend(tip.recipient.id);
				// Tip is older than 6 hours and has not been accepted
				var tipComment = {
					"sender": tip.recipient.name,
					"recipient": tip.sender.name,
					"refund": true,
					"USD": tip.amount * prices["GMC/USD"]
				};
				gamerscoin.move(tip.recipient.id, tip.sender.id, tip.amount, 1, stringifyAndEscape(tipComment), function(err: any, success: boolean) {
					if (err) {
						callback(err);
						return;
					}
					Collections.Tips.update({"_id": tip["_id"]}, {$set: {"refunded": true}}, {w:1}, callback);
				});
			}
			else {
				callback(null);
			}
		}, function(err) {
			if (err) {
				console.error("An error occurred: " + reportError(err, "Checking for expired tips to refund", true));
			}
		});
	});
开发者ID:hilmysyarif,项目名称:GamersSteamTipBot,代码行数:31,代码来源:bot.ts

示例2: function

 fs.readdir(dir, function (err, files) {
    var returnFiles = [];
    async.each(files, function (file, next) {
       var filePath = path.join(dir,file);
       fs.stat(filePath, function (err, stat) {
          if (err) { 
             return next(err);
          }
          if (stat.isDirectory()) {
             scan(filePath, suffix, function (err, results) {
                if (err) {
                   return next(err);
                }
                returnFiles = returnFiles.concat(results);
                next();
             })
          }
          else if (stat.isFile()) {
             if (file.indexOf(suffix, file.length - suffix.length) !== -1) {
                returnFiles.push(filePath);
             }
             next();
          }
       });
    }, function (err) {
       callback(err, returnFiles);
    });
 });
开发者ID:nil84,项目名称:tbt,代码行数:28,代码来源:FileUtil.ts

示例3: getLatestRelease

        getLatestRelease("https://github.com/superpowers/superpowers-core", (version, downloadURL) => {
          const packageData = fs.readFileSync(`${__dirname}/../../package.json`, { encoding: "utf8" });
          const { version: localVersion } = JSON.parse(packageData);

          let isLocalDev = true;
          try { if (!fs.lstatSync(`${__dirname}/../../.git`).isDirectory()) isLocalDev = false; }
          catch (err) { isLocalDev = false; }

          registry.core = { version, downloadURL, localVersion, isLocalDev };

          async.each(Object.keys(registry.systems), (systemId, cb) => {
            const system = registry.systems[systemId];
            getLatestRelease(system.repository, (version, downloadURL) => {
              system.version = version;
              system.downloadURL = downloadURL;

              if (systemsById[systemId] != null) {
                system.localVersion = systemsById[systemId].version;
                system.isLocalDev = systemsById[systemId].isDev;
              } else {
                system.isLocalDev = false;
              }

              cb();
            });
          }, (err) => { callback(err, registry); });
        });
开发者ID:andy737,项目名称:superpowers-core,代码行数:27,代码来源:utils.ts

示例4: cb

SupCore.system.serverBuild = (server: ProjectServer, buildPath: string, callback: (err: string) => void) => {
  fs.mkdirSync(`${buildPath}/files`);

  const assetIdsToExport: string[] = [];
  server.data.entries.walk((entry: SupCore.Data.EntryNode, parent: SupCore.Data.EntryNode) => {
    if (entry.type != null && server.system.data.assetClasses[entry.type].prototype.serverExport != null) assetIdsToExport.push(entry.id);
  });

  let files: string[] = [];

  async.each(assetIdsToExport, (assetId, cb) => {
    server.data.assets.acquire(assetId, null, (err: Error, asset: ServerExportableAsset) => {
      asset.serverExport(`${buildPath}/files`, (err, writtenFiles) => {
        server.data.assets.release(assetId, null);

        files = files.concat(writtenFiles);
        cb();
      });
    });
  }, (err) => {
    if (err != null) { callback("Could not export all assets"); return; }

    const json = JSON.stringify(files, null, 2);
    fs.writeFile(`${buildPath}/files.json`, json, { encoding: "utf8" }, (err) => {
      if (err != null) { callback("Could not save files.json"); return; }

      callback(null);
    });
  });
};
开发者ID:Wend1go,项目名称:superpowers-love2d,代码行数:30,代码来源:index.ts

示例5: Paper

        async.map(referenceParagraphs, resolveReferenceParagraph, (error, resolvedPapers: PaperRow[]) => {
          if (error) return callback(error);

          resolvedPapers.forEach((resolvedPaper, i) => {
            var matchString = resolvedPaper ? new Paper(resolvedPaper).toReference() : 'N/A';
            var matchDistance = resolvedPaper ? resolvedPaper['distance'] : '';
            logger.debug(`  "${chalk.yellow(referenceParagraphs[i])}" -> ${chalk.green(matchString)} ${chalk.magenta(matchDistance)}`);
          });

          // filter out the null resolved papers (no match)
          var citedPapers = resolvedPapers.filter(paper => !!paper);
          // insert all the resolved matches as citations
          async.each(citedPapers, (citedPaper: PaperRow, callback: ErrorCallback) => {
            db.Insert('citation')
            .set({
              citing_paper_id: article.id,
              cited_paper_id: citedPaper.id,
            })
            .execute(error => {
              // ignore unique constraint violations
              if (error && error.code === '23505') {
                return callback(null);
              }
              return callback(error);
            });
          }, (error) => {
            if (error) return callback(error);
            callback(null, {citing_paper_id: article.id, cited_papers_ids: citedPapers.map(paper => paper.id)});
          });
        });
开发者ID:chbrown,项目名称:acl,代码行数:30,代码来源:linker.ts

示例6: function

			.then (function (Documents) {
			
				// Ensure that the files have been recreated from the GridFS data
				async.each (Documents, retrieveFileFromDbWithCallback, function (err) {
					err ? reject (err) : resolve (Documents);
				});
			})
开发者ID:roderickmonk,项目名称:rod-monk-sample-repo,代码行数:7,代码来源:ttcGridFS.ts

示例7: load

export function load(contextNames: string[], callback: () => void) {
  async.each(contextNames, loadContext.bind(null, languageCode, contexts), () => {
    if (languageCode === "en") { callback(); return; }

    async.each(contextNames, loadContext.bind(null, "en", fallbackContexts), callback);
  });
}
开发者ID:mk-pmb,项目名称:superpowers-app,代码行数:7,代码来源:i18n.ts

示例8: before

      before(function(done) {
        TABLES[1].table = dataset.table(generateName('table'));
        TABLES[2].table = dataset.table(generateName('table'));

        async.each(
          TABLES,
          function(tableObject, next) {
            const tableInstance = tableObject.table;

            tableInstance.create(
              {
                schema: SCHEMA,
              },
              next
            );
          },
          function(err) {
            if (err) {
              done(err);
              return;
            }

            const table1Instance = TABLES[1].table;
            table1Instance.insert(TABLES[1].data, done);
          }
        );
      });
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:27,代码来源:bigquery.ts

示例9: setup

export function setup(toolPaths: { [name: string]: string; }, callback: Function) {
  toolsByName = {};

  const pluginsRoot = `/systems/${SupCore.system.id}/plugins`;

  async.each(Object.keys(toolPaths), (toolName, cb) => {
    const toolTitle = SupClient.i18n.t(`${toolPaths[toolName]}:editors.${toolName}.title`);
    const pluginPath = toolPaths[toolName];

    toolsByName[toolName] = { title: toolTitle, pluginPath, pinned: false };
    SupClient.fetch(`${pluginsRoot}/${pluginPath}/editors/${toolName}/manifest.json`, "json", (err: Error, toolManifest: ToolManifest) => {
      if (err != null) { cb(err); return; }

      toolsByName[toolName].pinned = toolManifest.pinned;
      cb();
    });
  }, (err) => {
    if (err != null) { callback(err); return; }

    toolsElt.innerHTML = "";

    const toolNames = Object.keys(toolsByName);
    toolNames.sort((a, b) => toolsByName[a].title.localeCompare(toolsByName[b].title));

    for (const toolName of toolNames) setupTool(toolName);
    callback();
  });
}
开发者ID:Pangoraw,项目名称:superpowers-core,代码行数:28,代码来源:tools.ts

示例10: join

        // handle copying or linking necessary assets
        cb => async.each(packs, (pack, next2) => {
          const dir = join(assetsDir, pack.id);

          if (pack.mode === 'images') {
            linkDirs(resolve(pack.path, pack.images.directory), dir, next2);
          } else if (pack.mode === 'sprite') {
            const filename = basename(pack.sprite.file);
            async.series([
              cb2 => mkdirp(dir, cb2),
              cb2 => copy(resolve(pack.path, pack.sprite.file), join(dir, filename), cb2),
            ], next2);
          } else { // pack.mode === 'font'
            const fontFiles = [
              pack.font.eot,
              pack.font.svg,
              pack.font.woff,
              pack.font.ttf,
              pack.font.woff2,
            ].filter(Boolean);

            async.series([
              cb2 => mkdirp(dir, cb2),
              cb2 => async.each(fontFiles, (file, next3) => {
                const filename = basename(file);
                copy(resolve(pack.path, file), join(dir, filename), next3);
              }, cb2),
            ], next2);
          }
        }, cb),
开发者ID:julianlam,项目名称:nodebb-plugin-emoji,代码行数:30,代码来源:build.ts


注:本文中的async.each函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。