test('Promise.promisify', function (t) { t.plan(4) twice(function () { var trans = ins.startTransaction() var readFile = Promise.promisify(require('fs').readFile) readFile(__filename, 'utf8').then(function (contents) { var firstLine = contents.split('\n')[0] t.ok(/use strict/.test(firstLine)) t.strictEqual(ins.currentTransaction.id, trans.id) }) }) })
/** * Instanciate Knox client * * @return {void} */ function initialise() { if (initialised) { return} initialised = true client = knox.createClient(mandi.config.aws) putFile = Promise.promisify(client.putFile.bind(client)) }
app.use(function *() { var form = new formidable.IncomingForm(); form.uploadDir = 'upload'; form.keepExtensions = true; var parse = Promise.promisify(form.parse, form); var uploaded = yield parse(this.req); console.log(uploaded); this.body = uploaded; });
static init(handler) { handler.run( "CREATE TABLE IF NOT EXISTS bitm (id integer primary key AutoIncrement, url text, hash varchar(20), timestamp integer)", () => { handler.run( "CREATE UNIQUE INDEX IF NOT EXISTS hash_index on bitm (hash)" ); handler.save_scheme = handler.prepare( "INSERT INTO bitm (url, hash, timestamp) VALUES (?, ?, ?)" ); handler.find_scheme = handler.prepare( "SELECT * FROM bitm where hash = ?" ); handler.find_scheme.get = bluebird.promisify( handler.find_scheme.get ); } ); }
/** * Read all rows from sheet. * * @returns {Promise.<[*]>} - array of sheet rows promise */ async getAllRows() { const getRows = Promise.promisify(this.sheet.getRows) return getRows({offset: this.headerRowHeight}) }
/** * Returns a promise of a `db` object. Subsequent calls to this function returns * the **same** promise, so it can be called any number of times without setting * up a new connection every time. */ const connect = () => { if (!process.env.MONGO_CONNECTION_STRING) { throw new DbError('Environment variable MONGO_CONNECTION_STRING must be set to use API.'); } return bluebird.promisify(MongoClient.connect)(process.env.MONGO_CONNECTION_STRING); }
bluebird.promisify(function(input, size, cb) { gm(input).resize(size).toBuffer(function(err, buffer) { if (err) cb(err); else cb(null, buffer); }); })
publishDeviceEvent(deviceType, deviceId, eventType, eventFormat, payload, qos) { const publishDeviceEvent = Promise.promisify(this.iotfAppClient.publishDeviceEvent.bind(this.iotfAppClient)); return publishDeviceEvent(deviceType, deviceId, eventType, eventFormat, payload, qos); }
get() { return Promise.promisify(CassandraClient.orm.close); }
publishDeviceCommand(deviceType, deviceId, eventType, eventFormat, payload, qos) { const publishDeviceCommand = Promise.promisify(this.iotfAppClient.publishDeviceCommand.bind(this.iotfAppClient)); return publishDeviceCommand(deviceType, deviceId, eventType, eventFormat, payload, qos); }
app.use(function *() { var form = new formidable.IncomingForm(); form.uploadDir = 'upload'; form.keepExtensions = true; var parse = Promise.promisify(form.parse, form); var uploaded = yield parse(this.req); console.log(uploaded); this.body = uploaded; });
get() { return Promise.promisify(CassandraClient.orm.close); }
get() { return Promise.promisify(this.orm.close); }
get() { return Promise.promisify(this.orm.close); }