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


TypeScript async.parallelLimit函数代码示例

本文整理汇总了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;未经允许,请勿转载。