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

TypeScript async.parallelLimit函数代码示例

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

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



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

示例1: function

  grunt.registerMultiTask('run_java', 'Run java on input files.', function() {
    var files: {src: string[]; dest: string}[] = this.files,
        done: (status?: boolean) => void = this.async(),
        tasks: Function[] = [];
    grunt.config.requires('build.java');
    files.forEach(function(file: {src: string[]; dest: string}) {
      if (fs.existsSync(file.dest) && fs.statSync(file.dest).mtime > fs.statSync(file.src[0]).mtime) {
        // No need to process file.
        return;
      }
      tasks.push(function(cb: (err?: any) => void) {
        // Trim '.java' from filename to get the class name.
        var class_name = file.src[0].slice(0, -5);
        child_process.exec(shellEscape(grunt.config('build.java')) + ' -Xbootclasspath/a:vendor/classes ' + class_name, function(err?: any, stdout?: NodeBuffer, stderr?: NodeBuffer) {
          fs.writeFileSync(file.dest, stdout.toString() + stderr.toString());
          cb();
        });
      });
    });

    async.parallelLimit(tasks, os.cpus().length, function(err?: any) {
      if (err) {
        grunt.fail.fatal('java failed: ' + err);
      }
      done();
    });
  });
开发者ID:danxexe,项目名称:doppio,代码行数:27,代码来源:java.ts


示例2: while

    fs.readdir(baseDir, (err, files) => {
        files = files.filter(f => f.indexOf('.errors.txt') > 0);
        let tasks: Array<(callback: () => void) => void> = [];
        files.forEach(f => tasks.push(done => {
            fs.readFile(baseDir + f, 'utf-8', (err, baseline) => {
                if (err) throw err;

                let g: string[];
                while (g = errRegex.exec(baseline)) {
                    var errCode = +g[1];
                    let msg = keys.filter(k => messages[k].code === errCode)[0];
                    messages[msg]['seen'] = true;
                }

                done();
            });
        }));

        async.parallelLimit(tasks, 25, done => {
            console.log('== List of errors not present in baselines ==');
            let count = 0;
            for (let k of keys) {
                if (messages[k]['seen'] !== true) {
                    console.log(k);
                    count++;
                }
            }
            console.log(count + ' of ' + keys.length + ' errors are not in baselines');
        });
    });
开发者ID:007jasonsmith,项目名称:TypeScript,代码行数:30,代码来源:errorCheck.ts


示例3: function

	grunt.registerMultiTask('unit_test', 'Run doppio unit tests.', function() {
    var files: {src: string[]; dest: string}[] = this.files,
        done: (status?: boolean) => void = this.async(),
        tasks: Function[] = [],
        options = this.options({args:[], secondary_file: ""});
    // Delete failures.txt if it exists.
    if (grunt.file.exists('classes/test/failures.txt')) {
      grunt.file.delete('classes/test/failures.txt');
    }
    files.forEach(function(file: {src: string[]; dest: string}) {
      tasks.push(function(cb: (err?: any) => void) {
        // Strip '.java'
        var name_no_ext = file.src[0].slice(0, -5);
        child_process.exec('node build/release-cli/console/test_runner.js ' + name_no_ext + ' --makefile', function(err?: any, stdout?: NodeBuffer, stderr?: NodeBuffer) {
          if (err) {
            grunt.log.write(stdout.toString() + stderr.toString());
          } else {
            grunt.log.write(stdout.toString());
          }
          cb();
        });
      });
    });

    async.parallelLimit(tasks, os.cpus().length, function(err?: any) {
      // Force newline after test output.
      grunt.log.writeln('');
      if (grunt.file.exists('classes/test/failures.txt')) {
        grunt.log.writeln(grunt.file.read('classes/test/failures.txt'));
      }
      done();
    });
  });
开发者ID:altoids,项目名称:doppio,代码行数:33,代码来源:unit_test.ts


示例4: function

	grunt.registerMultiTask('render', 'Run the Mustache renderer on input files.', function() {
    var files: {src: string[]; dest: string}[] = this.files,
        done: (status?: boolean) => void = this.async(),
        tasks: Function[] = [],
        options = this.options({args:[]});
    files.forEach(function(file: {src: string[]; dest: string}) {
      if (!grunt.file.exists(path.dirname(file.dest))) {
        grunt.file.mkdir(path.dirname(file.dest));
      }
      tasks.push(function(cb: (err?: any) => void) {
        // Strip '.mustache'
        var name_no_ext = path.basename(file.src[0]).slice(0, -9);
        child_process.exec('node node_modules/coffee-script/bin/coffee tools/render.coffee ' + options.args.join(' ') + ' ' + name_no_ext, function(err?: any, stdout?: NodeBuffer) {
          if (err) {
            grunt.fail.fatal('Error running render.coffee: ' + err);
          } else {
            fs.writeFileSync(file.dest, stdout);
          }
          cb();
        });
      });
    });

    async.parallelLimit(tasks, os.cpus().length, function(err?: any) {
      if (err) {
        grunt.fail.fatal('render.coffee failed: ' + err);
      }
      done();
    });
  });
开发者ID:altoids,项目名称:doppio,代码行数:30,代码来源:render.ts


示例5: function

  grunt.registerMultiTask('ice-cream', 'Removes debug statements from code.', function() {
    var ice_cream_path: string = 'node_modules/ice-cream/dessert.js',
        files: {src: string[]; dest: string}[] = this.files,
        done: (status?: boolean) => void = this.async(),
        args: string = " --remove trace --remove vtrace --remove debug",
        i: number, tasks: Function[] = [];
    for (i = 0; i < files.length; i++) {
      // Closure to capture 'file'.
      (function(file: {src: string[]; dest: string}) {
        // Ensure destination folder exists
        if (!fs.existsSync(path.dirname(file.dest))) {
          grunt.file.mkdir(path.dirname(file.dest));
        }
        tasks.push(function(cb: (err?: any) => void): void {
          grunt.util.spawn({
            cmd: 'node',
            args: [ice_cream_path, file.src[0], '--remove', 'trace', '--remove', 'vtrace', '--remove', 'debug']
          }, function(error, result, code) {
            if (code !== 0 || error) {
              grunt.fail.fatal("Could not run ice-cream on file " + file.src[0] + ": " + result.stdout + "\n" + result.stderr);
            }
            fs.writeFileSync(file.dest, result.stdout);
            cb(error);
          });
        });
      })(files[i]);
    }

    // Parallelize!
    async.parallelLimit(tasks, os.cpus().length, function(err: any, results: any[]) {
      done(err == null);
    });
  });
开发者ID:altoids,项目名称:doppio,代码行数:33,代码来源:ice-cream.ts


示例6: glob

        glob('**/tsconfig.json', { ignore: '**/node_modules/**' }, (error: Error | null, tsConfigFiles: string[]) => {
          if (error) {
            reject(error);
          }
          tsConfigFiles.forEach(file => {
            let args = ['-p', file];
            let taskFunction = (callback: TaskFunctionCallback) => {
              let task = taskRunner.runTask(`./node_modules/.bin/tsc`, args, {
                name: `tsc -p ${file}`,
                logger,
                handleOutput
              });
              runningTasks.push(task);
              task.result.then(() => {
                runningTasks.splice(runningTasks.indexOf(task), 1);
              }).then(callback).catch(reject);
            };

            taskFunctions.push(taskFunction);
          });

          let limit = 2;
          parallelLimit(taskFunctions, limit, resolve);
        });
开发者ID:AFASSoftware,项目名称:typescript-assistant,代码行数:24,代码来源:compiler.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript async.queue函数代码示例发布时间:2022-05-25
下一篇:
TypeScript async.parallel函数代码示例发布时间: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