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


TypeScript async.forEach函数代码示例

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


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

示例1: _

					fs.readdir(src, (err, files:string[]) => {
						if (err) return finish(err, ret);

						files = _(files).filter((name) => {
							return extDef.test(name);
						});

						if (files.length == 0) {
							return finish(null, ret);
						}

						async.forEach(files, (name, callback:(err) => void) => {
							//src + '/' + file + '/' + sub;
							var tmp = path.join(src, name);
							fs.stat(tmp, (err, stats) => {
								if (err) return callback(err);
								if (stats.isDirectory()) return callback(null);

								//console.log('-> def ' + name);
								ret.push(new Def(project, name.replace(extDef, '')));
								callback(null);
							});
						}, (err) => {
							finish(err, ret);
						});
					});
开发者ID:Bartvds,项目名称:tsd-deftools,代码行数:26,代码来源:loader.ts

示例2: callback

					(files:string[], callback:AsyncCallback) => {
						//check each file
						async.forEach(files, (file:string, callback:AsyncCallback) => {
							var full = path.join(dir, file);
							fs.stat(full, (err, stats)=> {
								if (err) return callback(err, null);
								if (stats.isFile()) {
									return fs.unlink(full, callback);
								}
								return callback(null, null);
							})
						}, callback);
					}
开发者ID:Bartvds,项目名称:tsd-deftools,代码行数:13,代码来源:helper.ts

示例3: callback

			fs.readdir(repos.defs, (err, files:string[]) => {
				if (err) return finish(err, []);

				var ret:Def[] = [];

				//check if these are folders containing a definition
				async.forEach(files, (file, callback:(err) => void) => {
					if (ignoreFile.test(file)) {
						return callback(false);
					}

					var src = path.join(repos.defs, file);

					fs.stat(src, (err, stats) => {
						if (err) return callback(false);
						if (!stats.isDirectory()) {
							return callback(false);
						}
						fs.readdir(src, (err, files:string[]) => {
							if (err) return callback(false);

							files = _(files).filter((name) => {
								return isDef.test(name);
							});

							async.forEach(files, (name, callback:(err) => void) => {
								//src + '/' + file + '/' + sub;
								var tmp = path.join(src, name);
								fs.stat(tmp, (err, stats) => {
									if (err) return callback(false);
									if (stats.isDirectory()) {
										return callback(false);
									}
									//console.log('-> ' + sub);
									ret.push(new Def(file, name.replace(isDef, '')));
									callback(null);
								});
							}, (err) => {
								callback(err);
							});
						});
					});

				}, (err) => {
					finish(err, ret);
				});
			});
开发者ID:Diullei,项目名称:tsd-deftools,代码行数:47,代码来源:loader.ts

示例4: function

            }).on('end', function () {
            console.log('Screenshots taken');

            let filestoUpload = [req.file.path.split('.mov')[0] + '.png', req.file.path];
            var publicUrl:string[] = [];
            //use async foreach to upload the local files to a new file to be created in your bucket.
            async.forEach(filestoUpload,
                (file, callback)=>bucket.upload(file, function (err) {
                    if (!err) {
                        publicUrl.push(format(
                            'https://storage.googleapis.com/%s/%s',
                            bucket.name, file.split('../uploads/')[1]));
                    }
                    callback();
                }),
                function (err) {
                    if (err) return next(err);
                    //Tell the user about the great success
                    res.status(200).send(JSON.stringify(publicUrl.sort()));
                });

        });
开发者ID:dadakoko,项目名称:play-server,代码行数:22,代码来源:videos.ts

示例5: _

						fs.readdir(src, (err, files:string[]) => {
							if (err) return callback(false);

							files = _(files).filter((name) => {
								return isDef.test(name);
							});

							async.forEach(files, (name, callback:(err) => void) => {
								//src + '/' + file + '/' + sub;
								var tmp = path.join(src, name);
								fs.stat(tmp, (err, stats) => {
									if (err) return callback(false);
									if (stats.isDirectory()) {
										return callback(false);
									}
									//console.log('-> ' + sub);
									ret.push(new Def(file, name.replace(isDef, '')));
									callback(null);
								});
							}, (err) => {
								callback(err);
							});
						});
开发者ID:Diullei,项目名称:tsd-deftools,代码行数:23,代码来源:loader.ts

示例6: function

connection.query("SELECT * FROM seeds where verified != 2", function (err, rows, fields) {
    if (err) {
        console.log(err);
    } else {
        async.forEach(rows, function (x : any, cb) {
            /*var mybuf = new Buffer(x.title.length * 3);
            mybuf.write(x.title, 0, x.title.length, 'latin1');
            var utf8title = (conv.convert(mybuf)).toString('utf8');*/
            console.log("adding seed title: %", x.title);
            var item = {};
            item['title'] = x.title;
            item['description'] = x.description;
            item['uri'] = x.url;
            item['attribution_uri'] = x.url;
            item['archive'] = "Reischauer Institute";
            switch (x.category) {
                case "website":
                    item['media_type'] = "website";
                    item['layer_type'] = "website";
                    break;
                case "blog":
                    item['media_type'] = "website";
                    item['layer_type'] = "website";
                    break;
                case "video":
                    item['media_type'] = "video";
                    item['layer_type'] = "video";
                    break;
                case "audio":
                    item['media_type'] = "audio";
                    item['layer_type'] = "audio";
                    break;
                case "photos":
                    item['media_type'] = "image";
                    item['layer_type'] = "image";
                    break;
                case "maps":
                    item['media_type'] = "website";
                    item['layer_type'] = "website";
                    break;
                default:
                    item['media_type'] = "website";
                    item['layer_type'] = "website";
            }
            item['location'] = x.location;
            item['media_geo_latitude'] = x.lat;
            item['media_geo_longitude'] = x.lng;

            item['media_date_created'] = x.added;
            item['media_creator_username'] = x.name;
            item['id_at_source'] = x.sid;

            item['attributes'] = {
                frequency: x.frequency,
                scope: x.scope,
                language: x.language,
                creator_email: x.email,
            };

            item['published'] = 1;
            var tags = x.tags.split(',');
            item['tags'] = [];
            for (var i = 0; i < tags.length; i++) {
                if (tags[i].trim() != "") {
                    item['tags'].push(tags[i].trim());
                }
            }
            jsonDict.items.push(item);
            cb();
        }, function (err) {
            fs.writeFileSync('output.json', JSON.stringify(jsonDict), 'utf8');
            console.log("Done!");
            process.exit(0);
        });
    }
});
开发者ID:ebensing,项目名称:jda-conversion,代码行数:76,代码来源:db-import.ts

示例7: innerCallback

              (err: Error | null, transferSubscriptionsResponse?: TransferSubscriptionsResponse) => {
                  if (err) {
                      // when transfer subscription has failed, we have no other choice but
                      // recreate the subscriptions on the server side
                      return innerCallback(err);
                  }
                  if (!transferSubscriptionsResponse) {
                      return innerCallback(new Error("Internal Error"));
                  }

                  const results = transferSubscriptionsResponse.results || [];

                  // istanbul ignore next
                  if (doDebug) {
                      debugLog(chalk.cyan("    =>  transfer subscriptions  done"),
                        results.map((x: any) => x.statusCode.toString()).join(" "));
                  }

                  const subscriptionsToRecreate = [];

                  // some subscriptions may be marked as invalid on the server side ...
                  // those one need to be recreated and repaired ....
                  for (let i = 0; i < results.length; i++) {

                      const statusCode = results[i].statusCode;
                      if (statusCode === StatusCodes.BadSubscriptionIdInvalid) {

                          // repair subscription
                          debugLog(chalk.red("         WARNING SUBSCRIPTION  "),
                            subscriptionsIds[i], chalk.red(" SHOULD BE RECREATED"));

                          subscriptionsToRecreate.push(subscriptionsIds[i]);
                      } else {
                          const availableSequenceNumbers = results[i].availableSequenceNumbers;

                          debugLog(chalk.green("         SUBSCRIPTION "), subscriptionsIds[i],
                            chalk.green(" CAN BE REPAIRED AND AVAILABLE "), availableSequenceNumbers);
                          // should be Good.
                      }
                  }
                  debugLog("  new session subscriptionCount = ", newSession.getPublishEngine().subscriptionCount);

                  async.forEach(subscriptionsToRecreate, (subscriptionId: SubscriptionId, next: ErrorCallback) => {

                        if (!session.getPublishEngine().hasSubscription(subscriptionId)) {
                            debugLog(chalk.red("          => CANNOT RECREATE SUBSCRIPTION  "), subscriptionId);
                            return next();
                        }
                        const subscription = session.getPublishEngine().getSubscription(subscriptionId);
                        assert(subscription.constructor.name === "ClientSubscriptionImpl");
                        debugLog(chalk.red("          => RECREATING SUBSCRIPTION  "), subscriptionId);
                        assert(subscription.session === newSession, "must have the session");

                        subscription.recreateSubscriptionAndMonitoredItem((err1?: Error) => {
                            if (err1) {
                                debugLog("_recreateSubscription failed !");
                            }

                            debugLog(chalk.cyan("          => RECREATING SUBSCRIPTION  AND MONITORED ITEM DONE "),
                              subscriptionId);

                            next();
                        });

                    }, (err1?: Error | null) => {
                        innerCallback(err1!);
                    }
                  );
              });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:69,代码来源:reconnection.ts

示例8: exec

 exec( args: ArgsCheckPrerequ, done: ( boolean ) => void ) {
     async.forEach( args.names, ( name, cb ) =>
         this.check_prerequ( name, ( err, fail ) => cb( err || fail ) )
     , done );
 }
开发者ID:hleclerc,项目名称:nsmake,代码行数:5,代码来源:CheckPrerequ.ts


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