• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript async.forEachSeries函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Promise

 return new Promise((res, rej) => {
   async.forEachSeries(todos, function(task:any, callback:any){
     tasks[task] && tasks[task](conf, callback);
   }, (err:any) => {
     if (err) return rej(err)
     return res()
   });
 })
开发者ID:duniter,项目名称:duniter,代码行数:8,代码来源:wizard.ts


示例2: afterJob

export function afterJob(plugins, ctx: ctxm.JobContext, wkCtx: ctxm.WorkerContext, jobSuccess: Boolean, callback: (err: any, success: boolean) => void): void {
    trace = new tm.Tracing(__filename, wkCtx);
    trace.enter('afterJob plugins');

    async.forEachSeries(plugins['afterJob'],
        function (plugin, done) {
            trace.write('afterJob plugin: ' + plugin.pluginName());

            if (!plugin.shouldRun(jobSuccess, ctx)) {
                trace.write('should not run');
                done();
                return;
            }

            ctx.info('Running afterJob for : ' + plugin.pluginName());

            ctx.writeConsoleSection('Running ' + plugin.pluginName());
            var logDescr = 'Plugin afterJob:' + plugin.pluginName();
            var pluginCtx: ctxm.PluginContext = new ctxm.PluginContext(ctx.job,
                ctx.authHandler,
                plugin.afterId,
                ctx.service,
                wkCtx);
            pluginCtx.on('message', function (message) {
                ctx.service.queueConsoleLine(message);
            });

            shell.cd(pluginCtx.buildDirectory);
            ctx.setTaskStarted(plugin.afterId, plugin.pluginName());
            plugin.afterJob(pluginCtx, function (err) {
                if (err) {
                    ctx.setTaskResult(plugin.afterId, plugin.pluginName(), ifm.TaskResult.Failed);
                    ctx.error(err);
                    pluginCtx.end();
                    done(err);
                    return;
                }

                ctx.setTaskResult(plugin.afterId, plugin.pluginName(), ifm.TaskResult.Succeeded);
                ctx.info('Done afterJob for : ' + plugin.pluginName());
                pluginCtx.end();
                done(null);
            });
        },
        function (err) {
            callback(err, !err);
        });
}
开发者ID:itsananderson,项目名称:vso-agent,代码行数:48,代码来源:plugins.ts


示例3: afterJob

export function afterJob(plugins: IPlugin[], executionContext: cm.IExecutionContext, hostContext: ctxm.HostContext, jobSuccess: boolean, callback: (err: any, success: boolean) => void): void {
    trace = new tm.Tracing(__filename, hostContext);
    trace.enter('afterJob plugins');

    async.forEachSeries(plugins['afterJob'],
        function (plugin: IPlugin, done) {
            trace.write('afterJob plugin: ' + plugin.pluginName());

            if (!plugin.shouldRun(jobSuccess, executionContext)) {
                trace.write('should not run');
                done();
                return;
            }

            hostContext.info('Running afterJob for : ' + plugin.pluginName());

            executionContext.writeConsoleSection('Running ' + plugin.pluginName());
            var logDescr = 'Plugin afterJob:' + plugin.pluginName();
            
            // create a new execution context with the before-job timeline record id
            var pluginContext = new ctxm.ExecutionContext(executionContext.jobInfo, executionContext.authHandler, plugin.afterId, executionContext.service, hostContext);
            
            pluginContext.on('message', function (message) {
                pluginContext.service.queueConsoleLine(message);
            });

            pluginContext.setTaskStarted(plugin.pluginName());
            plugin.afterJob(pluginContext, function (err) {
                if (err) {
                    pluginContext.setTaskResult(plugin.pluginName(), agentifm.TaskResult.Failed);
                    pluginContext.error(err);
                    pluginContext.end();
                    done(err);
                }
                else {
                    pluginContext.setTaskResult(plugin.pluginName(), agentifm.TaskResult.Succeeded);
                    hostContext.info('Done afterJob for : ' + plugin.pluginName());
                    pluginContext.end();
                    done(null);
                }
            });
        },
        function (err) {
            callback(err, !err);
        });
}
开发者ID:ElleCox,项目名称:vso-agent,代码行数:46,代码来源:plugins.ts


示例4: exec

    exec( args: ConcatYamlToJsonArgs, done: ( err: boolean ) => void ) {
        let res = new Array<any>();
        async.forEachSeries( args.directories, ( target, cb_dir ) => {
            this.get_filtered_target( target, target, ( err_fr: boolean, fr ) => {
                if ( err_fr || ! fr )
                    return cb_dir( false );
                const dir = fr.name;
                this.read_dir( dir, ( err, content ) => {
                    if ( err ) return cb_dir( false );

                    async.forEachSeries( content, ( name, cb_cnt ) => {
                        // skip if not a .yam file
                        if ( ! name.toLowerCase().endsWith( ".yaml" ) )
                            return cb_cnt( null );
                        // a way to store the dependancy (and potentially handle code generation)
                        this.get_filtered_target( path.resolve( dir, name ), dir, ( err, ft ) => {
                            if ( err )
                                return cb_cnt( null );
                            this.read_file( ft.name, ( err, str ) => {
                                try {
                                    const data = yaml.safeLoad( str.toString() );
                                    res.push( { name: path.join( dir, name ), data } );
                                } catch ( e ) {
                                    this.error( `Error:${ path.join( dir, name ) }:${ e }` );
                                }
                                cb_cnt( null );
                            } );
                        } );
                    }, err => cb_dir( false ) );
                } );
            } );
        }, ( err: boolean ) => {
            if ( err )
                return done( err );
            const out = this.new_build_file( `concat-yaml`, ".json", null, ( err, out ) => {
                if ( err ) return done( true );
                this.write_file( out, JSON.stringify( res ), ( err ) => {
                    if ( err ) return done( true );
                    this.outputs = [ out ];
                    done( false );
                } );
            } );
        } );
    }
开发者ID:hleclerc,项目名称:nsmake,代码行数:44,代码来源:ConcatYamlToJson.ts


示例5: function

    fs.readdir(folder, function (err, files) {
        if (err) {
            callback(err);
            return;
        }

        async.forEachSeries(files,
            function (item, done) {
                var pluginPath = path.join(folder, item);
                ctx.info('inspecting ' + pluginPath);
                if (path.extname(pluginPath) === '.js') {
                    try {
                        var plugin = require(pluginPath);

                        // ensure plugin - has name and title functions
                        if (isFunction(plugin.pluginName) && isFunction(plugin.pluginTitle)) {
                            ctx.info('Found plugin: ' + plugin.pluginName() + ' @ ' + pluginPath);

                            if (isFunction(plugin.beforeJob)) {
                                plugin.beforeId = uuid.v1();
                                plugins['beforeJob'].push(plugin);
                            }

                            // one plugin may have implementations of multiple options
                            if (isFunction(plugin.afterJobPlugins)) {
                                plugin.afterJobPlugins(jobContext).forEach((option: IPlugin) => {
                                    option.afterId = uuid.v1();
                                    plugins['afterJob'].push(option);
                                });
                            }
                        }
                    }
                    catch (ex) {
                        console.error(ex);
                    }
                }

                done();
            },
            function (err) {
                callback(err, plugins);
            });
    })
开发者ID:itsananderson,项目名称:vso-agent,代码行数:43,代码来源:plugins.ts


示例6: _cleanFiles

    private _cleanFiles(callback: (err: any) => void): void {
        this.emitter.emit('info', 'Cleaning Files: ' + this.path);
        if (!shell.test('-d', this.path)) {
            callback(null);
            return;
        }

        var candidates = shell.find(this.path).filter((file) => { return this.ext === '*' || file.endsWith('.' + this.ext); });

        var _that = this;
        var delCount = 0;
        async.forEachSeries(candidates,
            function (candidate, done: (err: any) => void) {
                fs.stat(candidate, (err, stats) => {
                    if (err) {
                        done(null);
                        return;
                    }

                    if (stats.isDirectory()) {
                        done(null);
                        return;
                    }

                    var fileAgeSeconds = (new Date().getTime() - stats.mtime.getTime()) / 1000;
                    if (fileAgeSeconds > _that.ageSeconds) {
                        ++delCount;
                        _that.emitter.emit('deleted', candidate);
                        shell.rm(candidate);
                    }                    

                    // ignoring errors - log and keep going
                    done(null);
                })
            }, function (err) {
                _that.emitter.emit('info', 'deleted file count: ' + delCount);
                // ignoring errors. log and go
                callback(null);
            });        
    }
开发者ID:itsananderson,项目名称:vso-agent,代码行数:40,代码来源:diagnostics.ts


示例7: cb_cnt

                this.read_dir( dir, ( err, content ) => {
                    if ( err ) return cb_dir( false );

                    async.forEachSeries( content, ( name, cb_cnt ) => {
                        // skip if not a .yam file
                        if ( ! name.toLowerCase().endsWith( ".yaml" ) )
                            return cb_cnt( null );
                        // a way to store the dependancy (and potentially handle code generation)
                        this.get_filtered_target( path.resolve( dir, name ), dir, ( err, ft ) => {
                            if ( err )
                                return cb_cnt( null );
                            this.read_file( ft.name, ( err, str ) => {
                                try {
                                    const data = yaml.safeLoad( str.toString() );
                                    res.push( { name: path.join( dir, name ), data } );
                                } catch ( e ) {
                                    this.error( `Error:${ path.join( dir, name ) }:${ e }` );
                                }
                                cb_cnt( null );
                            } );
                        } );
                    }, err => cb_dir( false ) );
                } );
开发者ID:hleclerc,项目名称:nsmake,代码行数:23,代码来源:ConcatYamlToJson.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript async.map函数代码示例发布时间:2022-05-25
下一篇:
TypeScript async.forEach函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap