How to use pull-stream - 10 common examples

To help you get started, we’ve selected a few pull-stream 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 validitylabs / hopr / src / network / natTraversal / signalling / index.js View on Github external
handleRequest(protocol, conn) {
        pull(
            /* prettier-ignore */
            conn,
            lp.decode(),
            pull.map(Message.decode),
            pull.drain(message => this.processMessage(conn, message))
        )
    }
github ipfs / js-ipfs-unixfs-engine / src / exporter / resolve.js View on Github external
return cb(null, resolveItem(null, item.object, item, options.offset, options.length))
      }

      const cid = new CID(item.multihash)

      dag.get(cid, (err, node) => {
        if (err) {
          return cb(err)
        }

        // const name = item.fromPathRest ? item.name : item.path
        cb(null, resolveItem(cid, node.value, item, options.offset, options.length))
      })
    }),
    pull.flatten(),
    pull.filter(Boolean),
    pull.filter((node) => node.depth <= options.maxDepth)
  )

  function resolveItem (cid, node, item, offset, length) {
    return resolve(cid, node, item.name, item.path, item.pathRest, item.size, dag, item.parent || parent, item.depth, offset, length)
  }

  function resolve (cid, node, name, path, pathRest, size, dag, parentNode, depth, offset, length) {
    let type

    try {
      type = typeOf(node)
    } catch (error) {
      return pull.error(error)
    }
github blockades / scuttle-dark-crystal / root / pull / mine.js View on Github external
const query = [{
      $filter: {
        value: {
          author: server.id,
          timestamp: { $gt: 0 }, // needed for how I set up /query page
          content: { type: 'dark-crystal/root' }
        }
      }
    }]

    const _opts = Object.assign({}, { query }, opts)
    // NOTE - this could benefit from a deeper merge?

    return pull(
      next(server.query.read, _opts),
      pull.filter(isRoot)
    )
  }
}
github ssbc / ssb-db / legacy.js View on Github external
function migrate () {
          // actual upgrade
          pull(
            db.createLogStream({gt: since}),
            paramap(function (data, cb) {
              prog.current += 1
              flumedb.rawAppend(data, cb)
            }, 32),
            pull.drain(null, ready)
          )
        }
      }
github dominictarr / pull-fs / test / read.js View on Github external
test('write a file', function (t) {
  var lines = ['a\n', 'b\n', 'c\n'].map(Buffer)
  var file = '/tmp/test-pfs-write'
  pull(
    pull.values(lines),
    pfs.write(file, function (err) {
      if(err) throw err
      fs.readFile(file, 'utf-8', function (err, data) {
        if(err) throw err
        t.equal(data, lines.join(''))
        t.end()
      })
    })
  )
})
github ssbc / ssb-ebt / test / simple.js View on Github external
function log (name) {
  return pull.through(function (data) {
    console.log(name, data)
  })
}
github ssbc / multi0a4db20406775263583a31603406b34b33bfe1e3 / test / size.js View on Github external
tape('add, size', function (t) {

  pull(
    pull.values(random1),
    blobs.add(function (err, hash) {
      if(err) throw err
      t.equal(hash, hash1)
      blobs.size(hash, function (_, size) {
        t.equal(size, 100*1024)
        t.end()
      })
    })
  )
})
github ssbc / multicfd64636ed26aacf9abe6a98e786c83caada3dc7 / test / live.js View on Github external
function hasher (ary) {
    var hasher = util.createHash(alg, true)
    pull(pull.values(ary), hasher, pull.drain())
    return util.encode(hasher.digest, alg)
  }
github ssbc / ssb-db / test / get-relays.js View on Github external
function all(stream, cb) {
  pull(stream, pull.collect(cb))
}
github ssbc / ssb-db / test / mesages-by-type.js View on Github external
function all (stream, cb) {
  pull(stream, pull.collect(cb))
}

pull-stream

minimal pull stream

MIT
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis