How to use run-parallel - 9 common examples

To help you get started, we’ve selected a few run-parallel 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 MovieCast / desktop / src / main / index.js View on Github external
function init() {
  let isReady = false; // app ready, windows can be created
  app.ipcReady = false; // main window has finished loading and IPC is ready
  app.isQuitting = false;

  parallel({
    appReady: (cb) => app.on('ready', () => cb(null)),
    store: (cb) => Store.load().then(store => cb(null, store)).catch(err => cb(err, null))
  }, onReady);

  function onReady(err, results) {
    if (err) throw err;

    isReady = true;

    // Install dev extensions
    extensions.init();

    // windows.app.init(results.store); // Restore the window to the last state we saved it in
    windows.app.init();
    // windows.engine.init(); // Not getting used anymore <3
    menu.init();
github mattdesl / codevember / src / 13.js View on Github external
import createErrorPage from './fatal-error'
import beats from 'beats'
import { freq2index } from './audio-util'
import SimplexNoise from 'simplex-noise'

const error = createErrorPage()
const AudioContext = window.AudioContext || window.webkitAudioContext

// dumb mobile test
const isMobile = /(iPad|iPhone|Android)/i.test(navigator.userAgent)
const simplex = new SimplexNoise()

if (isMobile || !AudioContext) {
  desktopOnly()
} else {
  parallel([
    (next) => {
      loadImage('assets/paper.png', next)
    },
    (next) => {
      soundcloud({
        client_id: 'b95f61a90da961736c03f659c03cb0cc',
        song: 'https://soundcloud.com/partyomo/partynextdoor-kehlanis-freestyle',
        dark: true,
        getFonts: true
      }, (err, src, data, div) => {
        if (err) return next(err)
        next(null, { src, data, div })
      })
    }
  ], onload)
}
github finnp / create-module / index.js View on Github external
name: name
  }

  var repo,
      processList = [
                      createDir,
                      gitInit,
                      createReadme,
                      createGitignore
                    ]

  if (!options.offline) processList.push(createGitHubrepo, gitRemoteAddOrigin)

  processList.push(npmInit, gitAddAndCommit)

  if (!options.offline) processList.push(parallel.bind(null, [gitPush, changeDescription]))

  if (options.check) processList.unshift(checkName)

  series(processList, function (err) {
    if (err) console.error('Error: ' + err.message)
    else console.log('Done.')
  })

  // Steps

  function checkName (cb) {
    console.log('Checking npm for pre-existing module name')
    request.head(registry + '/' + name, { headers: headers }, function (err, res) {
      if (err) return cb(err)
      if (res.statusCode === 200) return cb(new Error('"' + name + '" is already taken on npm.'))
      cb(null)
github tivac / crucible / src / types / upload.js View on Github external
return;
        }
        
        // Filter out non-images
        dropped = filter((e.dataTransfer || e.target).files, function(file) {
            return file.type.indexOf("image/") === 0;
        });
        
        if(ctrl.options.field.multiple) {
            ctrl.files = ctrl.files.concat(dropped);
        } else {
            ctrl.files = dropped.slice(-1);
        }
        
        // Load all the images in parallel so we can show previews
        parallel(
            ctrl.files
            .filter(function(file) {
                return !file.uploaded;
            })
            .map(function(file) {
                return function(callback) {
                    var reader = new FileReader();

                    reader.onload = function(result) {
                        file.src = result.target.result;
                        
                        callback();
                    };

                    reader.readAsDataURL(file);
                };
github uber-archive / idl / test / thrift-store.js View on Github external
}, function t(cluster, assert) {

    series([
        cluster.thriftStoreInstall.bind(cluster, 'github.com/org/b'),
        parallel.bind(null, {
            upstream: cluster.inspectUpstream.bind(cluster),
            localApp: cluster.inspectLocalApp.bind(cluster)
        })
    ], onResults);

    function onResults(err, results) {
        if (err) {
            assert.ifError(err);
        }
        var localApp = results[1].localApp;
        var upstream = results[1].upstream;

        var installedThriftFile =
            localApp.thrift['github.com'].org.b['service.thrift'];
        var installedMetaFile =
            JSON.parse(localApp.thrift['github.com'].org.b['meta.json']);
github digidem / mapeo-desktop / src / renderer / components / dialogs / Convert.js View on Github external
features.forEach(function (feature) {
      var task = (function () {
        return function (cb) {
          api.convert(feature, function (err, resp) {
            if (err) return cb(err)
            if (resp.statusCode !== 200) cb(new Error(resp.body))
            self.setState({ progress: self.state.progress + 1 })
            cb()
          })
        }
      })(feature)

      tasks.push(task)
    })

    parallel(tasks, function (err) {
      if (err) return console.error(err)
      self.props.changeView('MapEditor')
      this.setState({ progress: false })
    })
  }
github Raynos / mercury / bin / copy-markdown.js View on Github external
function getProject(uri, cb) {
    var projectUri = 'https://github.com/' + uri;
    var parts = uri.split('/');
    var folderName = parts[parts.length - 1];
    var dir = os.tmpDir();
    var folder = path.join(dir, folderName);

    series([
        gitrun.bind(null, ['clone', projectUri], dir),
        parallel.bind(null, {
            readme: fs.readFile.bind(null,
                path.join(folder, projects[uri]), 'utf8'),
            package: fs.readFile.bind(null,
                path.join(folder, 'package.json'), 'utf8')
        })
    ], function done(err, results) {
        if (err) {
            return cb(err);
        }

        var data = results[1];

        data.package = JSON.parse(data.package);
        data.name = data.package.name;

        logger.log('got', data.name);
github affanshahid / multer-storage-cloudinary / src / index.js View on Github external
_handleFile(req, file, cb) {

    runParallel(
      [
        this.getParams.bind(this, req, file),
        this.getFolder.bind(this, req, file),
        this.getFilename.bind(this, req, file),
        this.getTransformation.bind(this, req, file),
        this.getType.bind(this, req, file),
        this.getFormat.bind(this, req, file),
        this.getAllowedFormats.bind(this, req, file)
      ],
      (err, results) => {
        const params = results[0] || {
          folder: results[1],
          public_id: results[2],
          transformation: results[3],
          type: results[4],
          format: results[5],
github mattdesl / codevember / src / 15.js View on Github external
function load () {
  parallel([
    next => loadTexture('assets/15-lut.png', next),
    next => loadTexture('assets/dust.jpg', next)
  ], (err, [ lut, dust ]) => {
    if (err) {
      return error(err)
    }
    start3D(meshData, lut, dust)
  })
}

run-parallel

Run an array of functions in parallel

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis

Popular run-parallel functions