How to use the fromCallback function from bluebird

Find comprehensive JavaScript bluebird.fromCallback code examples handpicked from public code repositorys.

203
204
205
206
207
208
209
210
211
212
213
exports.editFile = function (str) {
  var pattern = Path.join(os.tmpdir(),'XXXXXX.yaml');
  var tmpfile = mktemp(pattern);
  fs.writeFileSync(tmpfile, str);


  return Promise.fromCallback(function (promiseCb) {
    editor(tmpfile, function (code) {
      if (code !== 0)
        return promiseCb(Error('Editor closed with code ' + code));

fork icon0
star icon0
watch icon5

+ 3 other calls in file

14
15
16
17
18
19
20
21
22
23
24
25
require('../../server/event-listeners').install();


function getKeys() {
  var redisClient = redis.getClient();


  return Promise.fromCallback(function(callback) {
    return redisClient.keys('unread:chat:*', callback);
  });
}

fork icon0
star icon0
watch icon0

+ 2 other calls in file

5
6
7
8
9
10
11
12
13
14
15
const { allowDestroy } = require('@packages/network')
const systemTests = require('../lib/system-tests').default


// create an HTTPS server that forces TLSv1
const startTlsV1Server = (port) => {
  return Bluebird.fromCallback((cb) => {
    const opts = _.merge({
      secureProtocol: 'TLSv1_server_method',
    }, cert)

fork icon0
star icon0
watch icon0

254
255
256
257
258
259
260
261
262
263
// about how Chrome does it.
context.skip('Google Chrome', () => {
  const testRetries = (path) => {
    return launchBrowser(`http://127.0.0.1:${PORT}${path}`)
    .then((proc) => {
      return Promise.fromCallback((cb) => {
        return onVisit = function () {
          if (counts[path] >= 3) {
            return cb()
          }
fork icon0
star icon0
watch icon0

+ 3 other calls in file

317
318
319
320
321
322
323
324
325
close () {
  const close = () => {
    const servers = _.values(sslIpServers).concat(this._sniServer)

    return Promise.map(servers, (server) => {
      return Promise.fromCallback(server.destroy)
      .catch(onError)
    })
  }
fork icon0
star icon0
watch icon0

242
243
244
245
246
247
248
249
250
251

stream.on('retry', () => {
  retries++
})

const p = Bluebird.fromCallback((cb) => {
  stream.on('error', cb)
})

return expect(p).to.be.rejected
fork icon0
star icon0
watch icon0

+ 11 other calls in file

169
170
171
172
173
174
175
176
177
    }

    redirectToStatus('error')
  })

  return new Promise.fromCallback((cb) => {
    server = app.listen(0, '127.0.0.1', cb)
  })
}
fork icon0
star icon0
watch icon0

+ 3 other calls in file