How to use the bluebird.all 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 akuma / evermark / src / Evermark.js View on Github external
async processStyles($, mathStyles) {
    // Get highlight theme from configuration
    const conf = await this.getConfig()
    const highlightTheme = conf.highlight || DEFAULT_HIGHLIGHT_THEME

    // Process html styles
    const styles = await Promise.all([
      mathStyles,
      fileUtils.readFile(path.join(MARKDOWN_THEME_PATH, 'github.css')),
      fileUtils.readFile(path.join(HIGHLIGHT_THEME_PATH, `${highlightTheme}.css`))
    ])
    const styleHtml =
      `<style>${styles.join('')}</style>` + `<div class="markdown-body">${$.html()}</div>`
    debug('styleHtml: %s', styleHtml)
    $.root().html(styleHtml)

    // Change html classes to inline styles
    const inlineStyleHtml = await inlineCss($.html(), {
      url: '/',
      removeStyleTags: true,
      removeHtmlSelectors: true
    })
    $.root().html(inlineStyleHtml)
github nusmodifications / nusmods / app / scripts / main.js View on Github external
localforage.getItem('migratedPreferences').then(function (value) {
  if (!value) {
    Promise.all(_.keys(config.defaultPreferences).map(function (property) {
      return localforage.getItem(property).then(function (value) {
        // Migration from old preferences to new namespaced preferencs.
        value = value ? value : config.defaultPreferences[property];
        localforage.setItem(preferencesNamespace + property, value);
      });
    }));
    localforage.setItem('migratedPreferences', true);
  }
});
github davidmcclure / earthxray / src / javascripts / scene / startup.js View on Github external
drawLabels() {

    let texture = new Promise(resolve => {
      THREE.ImageUtils.loadTexture('bm-fonts/lato.png', null, resolve);
    });

    let font = new Promise(resolve => {
      loadFont('bm-fonts/Lato-Regular-64.fnt', (err, font) => {
        resolve(font);
      });
    });

    // Wait for the texture and font.
    return Promise.all([texture, font]).spread((texture, font) => {
      for (let c of countryJSON.features) {

        if (!c.properties.anchor) continue;

        // Get 3D anchor.
        let [x, y, z] = utils.lonLatToXYZ(
          c.properties.anchor[0],
          c.properties.anchor[1]
        );

        let geometry = createText({
          font: font,
          text: c.properties.label,
        });

        let material = new THREE.MeshBasicMaterial({
github kartotherian / kartotherian / packages / tilerator / scripts / generateTiles.js View on Github external
tilenonsolid: 0,
        tiletoobig: 0,
        totalsize: 0
    };

    if (config.xy) {
        // Yield all values under the original X,Y square
        var mult = Math.pow(2, config.zoom - config.startZoom),
            x = config.xy[0] * mult,
            y = config.xy[1] * mult;
        nextTile = sc.getOptimizedIteratorFunc(config.zoom, util.xyToIndex(x, y), Math.pow(4, config.zoom - config.startZoom));
    } else {
        nextTile = sc.getOptimizedIteratorFunc(config.zoom);
    }

    return BBPromise
        .all(_.map(_.range(config.threads), renderTileAsync))
        .then(function () {
            config.reportStats(true);
            config.zoom++;
            if (config.zoom &lt;= config.endZoom) {
                return runZoom();
            }
        });
}
github hexojs / hexo / test / scripts / box / box.js View on Github external
it('watch() - rename folder', () => {
    const box = newBox('test');
    const path = 'a/b.txt';
    const src = pathFn.join(box.base, path);
    const newPath = 'b/b.txt';
    const newSrc = pathFn.join(box.base, newPath);
    const cacheId = 'test/' + path;
    const Cache = box.Cache;
    const processor = sinon.spy();

    box.addProcessor(processor);

    return Promise.all([
      fs.writeFile(src, 'a'),
      Cache.insert({_id: cacheId})
    ]).then(() => box.watch()).then(() => fs.rename(pathFn.join(box.base, 'a'), pathFn.join(box.base, 'b'))).delay(500).then(() => {
      const lastTwoCalls = processor.args.slice(processor.args.length - 2, processor.args.length);

      lastTwoCalls.forEach(args => {
        const file = args[0];

        switch (file.type) {
          case 'create':
            file.source.should.eql(newSrc);
            file.path.should.eql(newPath);
            break;

          case 'delete':
            file.source.should.eql(src);
github LiskHQ / lisk-sdk / test / integration / scenarios / stress / 5.register_dapp.js View on Github external
before(() => {
				var dappName;
				transactions = [];
				return Promise.all(
					_.range(maximum).map(num => {
						dappName = randomUtil.applicationName();
						var transaction = lisk.transaction.createDapp({
							passphrase: accounts[num].passphrase,
							options: {
								name: dappName,
								category: 1,
								description: 'desc',
								tags: '2',
								type: 0,
								link: `https://github.com/blocksafe/SDK-notice/${dappName}/master.zip`,
								icon: `http://www.blocksafefoundation.com/${dappName}/header.jpg`,
							},
						});
						transactions.push(transaction);
						return sendTransactionsPromise([transaction]);
github alexklibisz / firebak / src / restore.js View on Github external
converter.fromFile(filename , (error, result) => {
        if (error) reject(error);
        else resolve(result);
      });
    });

  while(fileContents.length > 0) {
    const promises = fileContents.splice(0, 100).map(object => {
      const {path, value} = object;
      if (overwrite) {
        return ref.child(path).set(value)
      } else {
        return setIfNull(path, value);
      }
    });
    await Promise.all(promises);
  }

}
github Vincit / objection.js / src / queryBuilder / EagerFetcher.js View on Github external
let relation = this.modelClass.getRelations()[child.name];

      if (!relation) {
        throw new ValidationError({eager: 'unknown relation "' + child.name + '" in an eager expression'});
      }
    });

    _.each(this.modelClass.getRelations(), relation => {
      let nextEager = this.eager.childExpression(relation.name);

      if (nextEager) {
        promises.push(this._fetchRelation(relation, nextEager));
      }
    });

    this.promise = Promise.all(promises).return(this.models);
    return this.promise;
  }
github intel-iot-devkit / littleb / src / wrappers / nbind / node_modules / asyncawait / comparison / fibonacci / fibonacci-bluebird.js View on Github external
var fibonacci = function (n) {
    if (n &lt;= 1) {
        return Promise.resolve(1);
    } else {
        return Promise.all([
            fibonacci(n - 1),
            fibonacci(n - 2)
        ])
        .spread(function (lhs, rhs) {
            return Promise.resolve(lhs + rhs);
        });
    }
}
github pubpub / pubpub / server / routes / explore.js View on Github external
'id',
			'subdomain',
			'domain',
			'title',
			'description',
			'heroBackgroundImage',
			'heroLogo',
			'accentColor',
			'accentTextColor',
			'createdAt',
			'updatedAt',
		],
		...whereQuery,
	});

	return Promise.all([getInitialData(req), getActiveCommunities])
		.then(([initialData, activeCommunitiesData]) =&gt; {
			const newInitialData = {
				...initialData,
				exploreData: { activeCommunities: activeCommunitiesData },
			};
			return renderToNodeStream(
				res,