How to use cont - 6 common examples

To help you get started, we’ve selected a few cont 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 ssbc / ssb-identities / test / index.js View on Github external
sbot.identities.list(function (err, ls) {
    if(err) throw err
    cont.para(
      ls.map(function (id) {
        return function (cb) {
          sbot.identities.publishAs({id: id, content: {type:'post', text: 'hello'}}, cb)
        }
      })
    )(function (err, ary) {
      if(err) throw err
      console.log(ary)
      ary.forEach(function (e, i) {
        t.equal(e.value.author, ls[i])
      })
      t.end()
    })
  })
})
github ssbc / ssb-ebt / test / index.js View on Github external
if(!recv[n][k]) missing ++
        else            has ++
      }
    }

    console.log('missing/has' ,missing, has)
    if(!missing)
      console.log('CONSISTENT!!!')
  }
}

a_bot.post(consistent('alice'))
b_bot.post(consistent('bob'))
c_bot.post(consistent('charles'))

cont.para(feeds.map(function (f) {
  return function (cb) {
    return f.publish({type:'post', text: 'hello world'}, cb)
  }
}))(function () {

  function log (name) {
    return pull.through(function (data) {
      console.log(name, data)
    })
  }

  function peers (a, b, name1, name2, d) {
    var a_rep = a.ebt.replicate.call({id: name2}, {version: 2})
    var b_rep = b.ebt.replicate.call({id: name1}, {version: 2})

    pull(
github ssbc / ssb-ebt / test / simple.js View on Github external
pull(
    a_rep,
    Delay(d),
    log(name1+'->'+name2),
    b_rep,
    Delay(d),
    log(name2+'->'+name1),
    a_rep
  )
}


a_bot.post(consistent('alice'))
b_bot.post(consistent('bob'))

cont.para(feeds.map(function (f) {
  return f.publish({type:'post', text: 'hello world'})
}))(function () {
  peers(a_bot, b_bot, 'a', 'b', 10)
})

var i = N
var int = setInterval(function () {
  var feed = feeds[~~(rng.random()*feeds.length)]
  feed.publish({type:'post', text: i.toString()}, function () {})

  if(--i) return

  clearInterval(int)

  console.log('Alice', a_bot.since())
  console.log('Bob', b_bot.since())
github mmckegg / patchwork-next / old_modules / notifications.js View on Github external
function isAnyOurMessage (msg, ids, cb) {
    cont.para(ids.map(function (id) {
      return function (cb) { isOurMsg(id, cb) }
    }))(function (err, results) {
      if (err) cb(err)
      else if (results.some(Boolean)) cb(null, msg)
      else cb()
    })
  }
github Happy0 / ssb-chess / modules_extra / notifications.js View on Github external
function isAnyOurMessage(msg, ids, cb) {
      cont.para(ids.map(function (id) {
        return function (cb) { isOurMsg(id, cb) }
      }))
      (function (err, results) {
        if (err) cb(err)
        else if (results.some(Boolean)) cb(null, msg)
        else cb()
      })
    }
github flumedb / flumedb / index.js View on Github external
rebuild: function (cb) {
      throwIfClosed('rebuild')
      return cont.para(map(flume.views, function (sv) {
        return function (cb) {
          //destroying will stop createSink stream
          //and flumedb will restart write.
          sv.destroy(function (err) {
            if(err) return cb(err)
            //when the view is up to date with log again
            //callback, but only once, and then stop observing.
            //(note, rare race condition where sv might already be set,
            //so called before rm is returned)
            var rm = sv.since(function (v) {
              if(v === log.since.value) {
                var _cb = cb; cb = null; _cb()
              }
              if(!cb && rm) rm()
            })
          })

cont

continuables in a handy-dandy grab bag, ready to go in case of an emergency.

MIT
Latest version published 10 years ago

Package Health Score

42 / 100
Full package analysis

Popular cont functions