How to use the bluebird.promisifyAll 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 Musicoin / desktop / hub / web3things.js View on Github external
const Promise = require('bluebird');
const Web3 = require('web3');
const console = require('./console.log.js');
const etherSettings = require('./ether.settings.js')
const Hook = require('hooked-web3-provider');
const Lightwallet = require('eth-lightwallet');
Promise.promisifyAll(Lightwallet.keystore);

module.exports = (function (data) {
	var web3 = new Web3();
	var watchReadyInterval = null;
	var watchSyncInterval = null;
	var connected = false;
	var currentKeystore = null;
	var keystore = new Lightwallet.keystore();
	var hook = new Hook({
	  host: etherSettings.etherServerRpc,
	  transaction_signer: keystore
	});

	// to be supplied internationalized by app
	this.errors = {
		noConnection: 'Not connected to client. Cannot proceed',
github masumsoft / express-cassandra / src / validators / datatypes.js View on Github external
const Promise = require('bluebird');
const util = require('util');
const check = require('check-types');

let dseDriver;
try {
  // eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved
  dseDriver = require('dse-driver');
} catch (e) {
  dseDriver = null;
}

const cql = Promise.promisifyAll(dseDriver || require('cassandra-driver'));

const validators = {};
validators.is_array = (obj) => (check.array(obj));
validators.is_object = (obj) => (check.object(obj));
validators.is_long = (obj) => ((obj instanceof cql.types.Long));
validators.is_decimal = (obj) => ((obj instanceof cql.types.BigDecimal));
validators.is_integer = (obj) => (check.integer(obj));
validators.is_var_int = (obj) => ((obj instanceof cql.types.Integer));
validators.is_boolean = (obj) => ((obj === true || obj === false));
validators.is_number = (obj) => (check.number(obj));
validators.is_string = (obj) => (check.string(obj));
validators.is_local_date = (obj) => ((obj instanceof cql.types.LocalDate));
validators.is_local_time = (obj) => ((obj instanceof cql.types.LocalTime));
validators.is_date = (obj) => (check.date(new Date(obj)));
validators.is_buffer = (obj) => ((obj instanceof Buffer));
validators.is_timeuuid = (obj) => ((obj instanceof cql.types.TimeUuid));
github jenkinsci / blueocean-plugin / jenkins-design-language / bin / import-material-icons.js View on Github external
**                                                                          **
**   Copies the files to JDL, while removing references to recompose/pure   **
**                                                                          **
**   USAGE: bin/import-material-icons.js /path/to/checkouts/material-ui     **
**                                                                          **
******************************************************************************
`;

const Bluebird = require('bluebird');
const fs = require('fs');
const Spinner = require('cli-spinner').Spinner;
const pathUtils = require('path'); // Renaming to avoid dumb errors :)

const jdlPackageJSON = require('../package.json');

Bluebird.promisifyAll(fs);

//--------------------------------------------------------------------------
//  Config

const sourcePackageName = 'material-ui-build';
const sourceIconSubdir = 'src/svg-icons'; // Subdir within checkout where the icons live
const relativeDestPath = './src/js/components/material-ui/svg-icons/';

//--------------------------------------------------------------------------
//  Main

function main() {

    const jdlPath = getJDLPath();
    const destPath = pathUtils.resolve(jdlPath, relativeDestPath);
    const sourceCheckoutPath = getSourceCheckoutPath();
github Canop / miaou / libs / db.js View on Github external
//  .catch(function(err){
//	    alert(err);
//      this.rollback();
//   }).finally(db.off);
//
//  The prefered way to use this is now with async/await:
//
//  await db.do(async function(con){
//       await con.doSomeThing();
//       await con.doSomeOtherOne();
//  }, onError(err){
//       handleErr();
//  });

const	Promise = require("bluebird"),
	fs = Promise.promisifyAll(require("fs")),
	bench = require("./bench.js"),
	path = require("path");

var	pg = require('pg'),
	config,
	pool;

Promise.longStackTraces(); // this will be removed in production in the future

// The connection object which is used for all postgress accesses from other files
function Con(){}
var proto = Con.prototype;

var NoRowError = exports.NoRowError = function(){
	this.message = "No Row";
};
github balena-io-modules / etcher-image-write / tests / images.spec.js View on Github external
*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

const m = require('mochainon');
const path = require('path');
const zlib = require('zlib');
const PassThroughStream = require('stream').PassThrough;
const Bluebird = require('bluebird');
const fs = Bluebird.promisifyAll(require('fs'));
const imageWrite = require('../lib/index');

const images = [
  path.join(__dirname, 'images', 'divisible-by-1024kb'),
  path.join(__dirname, 'images', 'divisible-by-512kb'),
  path.join(__dirname, 'images', 'divisible-by-128b'),
  path.join(__dirname, 'images', 'divisible-by-65536b'),
  path.join(__dirname, 'images', 'gzip'),
  path.join(__dirname, 'images', 'not-divisible-by-pow-2')
];

describe('E2E: Images', function() {

  images.forEach((dirname) => {
    it(path.basename(dirname), function() {
github iExecBlockchainComputing / iexec-stack / test / 05_buyForWorkOrder.js View on Github external
var DatasetHub     = artifacts.require("./DatasetHub.sol");
var WorkerPool     = artifacts.require("./WorkerPool.sol");
var App            = artifacts.require("./App.sol");
var WorkOrder      = artifacts.require("./WorkOrder.sol");
var IexecLib       = artifacts.require("./IexecLib.sol");
var Marketplace    = artifacts.require("./Marketplace.sol");

const Promise         = require("bluebird");
const fs              = require("fs-extra");
//extensions.js : credit to : https://github.com/coldice/dbh-b9lab-hackathon/blob/development/truffle/utils/extensions.js
const Extensions      = require("../utils/extensions.js");
const addEvmFunctions = require("../utils/evmFunctions.js");
const readFileAsync = Promise.promisify(fs.readFile);

addEvmFunctions(web3);
Promise.promisifyAll(web3.eth,     { suffix: "Promise" });
Promise.promisifyAll(web3.version, { suffix: "Promise" });
Promise.promisifyAll(web3.evm,     { suffix: "Promise" });
Extensions.init(web3, assert);
var constants = require("./constants");

contract('IexecHub', function(accounts) {

	let scheduleProvider, resourceProvider, appProvider, datasetProvider, dappUser, dappProvider, iExecCloudUser, marketplaceCreator;
	let subscriptionLockStakePolicy    = 0;
	let subscriptionMinimumStakePolicy = 10;
	let subscriptionMinimumScorePolicy = 0;
	let isTestRPC;
	let txMined;
	let txsMined;
	let testTimemout = 0;
	let aRLCInstance;
github yedf / micro-service / src / app.ts View on Github external
export function globalInit() {
  if (globalInited) return;
  globalInited = true;
  let begin = new Date().getTime();
  require("date-format-lite");
  Date['masks']['default'] = 'YYYY-MM-DD hh:mm:ss';
  require('babel-polyfill');
  let bluebird = require('bluebird');
  if (!fs.statAsync) {
    bluebird.promisifyAll(fs);
    fs.existsAsync = path => {
      return new Promise(resolve=>{
        fs.exists(path, r=>resolve(r));
      });
    };
  }
  process.on('unhandledRejection', (reason, p) => {
    console.log('---------------------------unhandledRejection:', reason);
  });
  console.log(`global inited. used: ${new Date().getTime()-begin} ms`);
}
github heroku / cli / client / lib / plugins.js View on Github external
'use strict'

const dirs = require('./dirs')
const path = require('path')
const json = require('./json')
const Promise = require('bluebird')
const fs = Promise.promisifyAll(require('fs-extra'))
const co = require('co')
const cli = require('heroku-cli-util')

function readRef (ref) {
  let name = ref
  let scope, version

  if (name[0] === '@') {
    let idx = ref.indexOf('/')
    scope = ref.slice(0, idx)
    name = ref.slice(idx + 1)
  }

  if (name.indexOf('@') !== -1) {
    [name, version] = name.split('@')
  }
github ottomatica / Baker / lib / modules / servers.js View on Github external
const child_process = require('child_process');
const { promisify } = require('util');
const execAsync     = promisify(child_process.exec);
const conf          = require('../../lib/modules/configstore');
const download      = require('download');
const fs            = require('fs-extra');
const md5File       = require('md5-file/promise')
const mustache      = require('mustache');
const os            = require('os');
const path          = require('path');
const print         = require('./print');
const Spinner       = require('../modules/spinner');
const spinnerDot    = conf.get('spinnerDot');
const Ssh           = require('./ssh');
const Utils         = require('./utils/utils');
const vagrant       = Promise.promisifyAll(require('node-vagrant'));

const vbox               = require('node-virtualbox');
const VBoxProvider       = require('node-virtualbox/lib/VBoxProvider');
const VirtualboxProvider = require('./providers/virtualbox');
const VagrantProvider    = require('./providers/vagrant');
const VagrantProviderObj = new VagrantProvider();

const { configPath, boxes, bakerForMacPath, bakerSSHConfig } = require('../../global-vars');

class Servers {
    constructor() {}

    static async stopBakerServer(forceVirtualBox = false) {
        if (require('os').platform() === 'darwin' && !forceVirtualBox) {
            try {
                await execAsync(`ps aux | grep -v grep | grep "${path.join(bakerForMacPath, 'bakerformac.sh')}" | awk '{print $2}' | xargs kill`);
github bezoerb / generator-sf / generators / buildtool / grunt / index.js View on Github external
'use strict';
const Bluebird = require('bluebird');
const fs = require('fs-extra');
const common = require('../_common');

Bluebird.promisifyAll(fs);

module.exports = common.extend({
  constructor: function () {
    common.apply(this, arguments);
  },

  configuring: {
    common: function () {
      this.props.noBower = this.props.loader === 'webpack' || this.props.loader === 'browserify' || this.props.loader === 'jspm';
    }
  },

  writing: {
    pkgScripts: function () {
      const pkg = this._readPkg();
      pkg.scripts.test = 'grunt test';