How to use the bluebird.map function in bluebird

To help you get started, we’ve selected a few bluebird 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 untu / comedy / test / typescript / test-clustered-actor.ts View on Github external
it('should not send messages to crashed forked actors', async function () {
      // Define test behaviour.
      let def = {
        kill: () => {
          process.exit(1);
        },

        getPid: () => process.pid
      };

      // Create clustered forked actor.
      let actor = await rootActor.createChild(def, {mode: 'forked', clusterSize: 2});

      // Get child actor PIDs.
      let pids = await P.map(_.range(2), () => actor.sendAndReceive('getPid'));

      // Kill first child.
      await actor.send('kill');

      // Wait for child to die.
      await tu.waitForCondition(() => !isRunning(pids[0]));

      // Send getPid message again. Second PID should be received.
      let pid2 = await actor.sendAndReceive('getPid');

      expect(pid2).to.be.equal(pids[1]);

      // Send getPid message again. First actor should be skipped as crashed.
      let pid = await actor.sendAndReceive('getPid');

      expect(pid).to.be.equal(pids[1]);
github epochtalk / core / tests / keys.js View on Github external
// 2 board last thread title
        // 2 board post count
        // 2 board thread count
        // 2 board total post count
        // 2 board total thread count
        // post post order
        // thread first post id
        // thread last post created at
        // thread last post username
        // thread post count
        // thread order
        // thread title
        // thread username
        // view count
        metadata.should.have.length(25);
        return Promise.map(metadata, function(data) {
          return probe.del(METADATA, data.key);
        });
      });
    });
github stelace / stelace / src / models / InternalAvailability.js View on Github external
const { startDate, endDate, quantity } = chunkAvailability

          const dbStartDate = startDate || '-infinity'
          const dbEndDate = endDate || 'infinity'

          await InternalAvailability.query(trx).insert({
            assetId: asset.id,
            datesRange: raw('tstzrange(?, ?)', [dbStartDate, dbEndDate]),
            startDate: dbStartDate,
            endDate: dbEndDate,
            quantity
          })
        }, { concurrency: 5 })

        // add computed chunk transactions to speed up availability query
        await bluebird.map(chunkTransactions, async (chunkTransaction) => {
          const { id, status, startDate, endDate, quantity, assetTypeId } = chunkTransaction

          const dbStartDate = startDate || '-infinity'
          const dbEndDate = endDate || 'infinity'

          const transaction = transactionsById[id]

          await InternalAvailability.query(trx).insert({
            assetId: asset.id,
            transactionId: id,
            transactionStatus: status,
            assetTypeId,
            unavailable: isStatusBlockingAvailability(transaction, status),
            datesRange: raw('tstzrange(?, ?)', [dbStartDate, dbEndDate]),
            startDate: dbStartDate,
            endDate: dbEndDate,
github ikhsanalatsary / multer-sharp / index.js View on Github external
_uploadWithMultipleSize(
    sizes,
    file,
    filename,
    gcName,
    fileOptions,
    stream,
    cb
  ) {
    Promise.map(
      sizes,
      this._eachUpload(file, filename, gcName, fileOptions, stream)
    )
      .then((results) => {
        // All resolve, do something
        const mapArrayToObject = results.reduce((acc, curr) => {
          acc[curr.suffix] = {};
          acc[curr.suffix].path = curr.path;
          acc[curr.suffix].filename = curr.filename;
          return acc;
        }, {});
        cb(null, mapArrayToObject);
        return null;
      })
      .catch(cb);
  }
github nspragg / filehound / src / filehound.js View on Github external
find(cb) {
    this._initFilters();

    const searchAsync = this._searchAsync.bind(this);
    const searches = Promise.map(this.getSearchPaths(), searchAsync);

    return Promise
      .all(searches)
      .reduce(flatten)
      .map(getFilename)
      .catch((e) => {
        this.emit('error', e);
        throw e;
      })
      .finally(() => {
        this.emit('end');
      })
      .asCallback(cb);
  }
github azukiapp / azk / src / libexec / profiling / send_benchmark_data_to_keen_io.js View on Github external
.then(function (files) {
    return BB.map(files, function (file) {
      return fs.readFileAsync(file)
        .then(function (content) {
          var error_found = typeof getFirstGroupRegex(content.toString(), /(error)/) !== 'undefined';
          if (error_found) {
            return 'Error string found on: ' +
              file                           +
              '\n----------->>\n'            +
              content.toString()             +
              '\n<<-----------\n';
          }
          return null;
        });
    });
  })
}
github cypress-io / cypress / packages / driver / src / cy / keyboard.ts View on Github external
.then(() => {
      if (options.release !== false) {
        return Promise.map(modifierKeys, (key) => {
          options.id = _.uniqueId('char')

          return this.simulatedKeyup(getActiveEl(doc), key, options)
        })
      }

      return []
    })
    .then(options.onAfterType)
github Nexus-Mods / vortex-games / game-bladeandsorcery / index.js View on Github external
const filtered = files.filter(file =>
          ((file.indexOf(rootPath) !== -1)
          && (!file.endsWith(path.sep))));

        const instructions = filtered.map(file => {
          return {
            type: 'copy',
            source: file,
            destination: path.join(modName, file.substr(idx)),
          };
        });

        return Promise.resolve(instructions);
      });

  return Promise.map(manifestFiles, manFile =>
    checkModGameVersion(destinationPath, minModVersion, manFile)
    .then(res => (!res.match)
      ? versionMismatchDialog(res.globalVersion, res.modVersion)
          .then(() => createInstructions(manFile))
      : createInstructions(manFile))
  ).then(manifestMods => {
    const instructions = manifestMods.reduce((prev, instructions) => {
      prev = prev.concat(instructions);
      return prev;
    }, []);

    return Promise.resolve({ instructions });
  });
}
github dasilvacontin / animus / app / js / event-utils.js View on Github external
exports.emitP = function emitP (emitter, event, args) {
  args = Array.prototype.slice.call(args, 2)
  return Promise.map(emitter.listeners(event), function (handler) {
    var result = handler.apply(emitter, args)
    return result
  })
}