How to use run-parallel-limit - 5 common examples

To help you get started, we’ve selected a few run-parallel-limit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / just / packages / just-scripts / src / tasks / cleanTask.ts View on Github external
logger.info(`Removing [${paths.map(p => path.relative(process.cwd(), p)).join(', ')}]`);

    const cleanTasks = paths
      .map(
        cleanPath =>
          function(cb: (error: Error | null) => void) {
            fse.remove(cleanPath, cb);
          }
      )
      .concat((cb: (error: Error | null) => void) => {
        clearCache();
        cb(null);
      });

    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
    parallelLimit(cleanTasks, limit!, done);
  };
}
github microsoft / just / packages / just-scripts / src / tasks / sassTask.ts View on Github external
const css = result.css.toString();

                  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
                  postcss([autoprefixerFn, ...postcssPlugins!])
                    .process(css, { from: fileName })
                    .then((result: { css: string }) => {
                      fs.writeFileSync(fileName + '.ts', createSourceModule(fileName, result.css));
                      cb();
                    });
                }
              }
            );
          }
      );

      parallelLimit(tasks, 5, done);
    } else {
      done();
    }
  };
}
github digidem / mapeo-desktop / src / renderer / create-zip.js View on Github external
console.log('Req end in ' + (Date.now() - start) + 'ms ' + metadataPath)
        zipfile.addBuffer(Buffer.from(arrBuf), metadataPath, {
          ...options,
          store: true
        })
        cb()
      })
      .catch(err => {
        missing.push(metadataPath)
        console.log('Error downloading file ' + metadataPath, err)
        cb()
      })
  })
  const start = Date.now()
  console.log('Starting download')
  run(tasks, concurrency, (...args) => {
    console.log('Downloaded images in ' + (Date.now() - start) + 'ms')
    if (missing.length) {
      zipfile.addBuffer(
        Buffer.from(missing.join('\r\n') + '\r\n'),
        'missing.txt'
      )
    }
    zipfile.end()
  })

  return zipfile.outputStream
}
github microsoft / just / packages / just-task-preset / src / outdatedTask.ts View on Github external
const cp = spawn(npmCmd, npmArgs, { stdio: 'pipe' });
          let json = '';

          cp.stdout.on('data', (data: any) => {
            json = json + data.toString();
          });

          cp.on('exit', code => {
            const info = JSON.parse(json);
            versionInfo[name] = { tags: info['dist-tags'], versions: info['versions'] };
            cb();
          });
        }
    );

    parallelLimit(checkVersionTasks, 5, () => {
      resolve(versionInfo);
    });
  });
}
github microsoft / just / packages / just-scripts / src / tasks / copyTask.ts View on Github external
const readStream = fse.createReadStream(matchedPath);
          const destPath = path.join(dest!, relativePath);

          if (!fse.existsSync(path.dirname(destPath))) {
            fse.mkdirpSync(path.dirname(destPath));
          }

          readStream.pipe(fse.createWriteStream(destPath));
          readStream.on('error', err => cb(err));
          readStream.on('end', cb);
        });
      });
    }

    paths.forEach(copyPath => helper(copyPath));
    parallelLimit(copyTasks, limit!, done);
  };
}

run-parallel-limit

Run an array of functions in parallel, but limit the number of tasks executing at the same time

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis

Popular run-parallel-limit functions