How to use the values function from pull-stream

Find comprehensive JavaScript pull-stream.values code examples handpicked from public code repositorys.

pull-stream.values is a function that creates a stream that outputs the given set of values.

172
173
174
175
176
177
178
179
180
181
-----1--2----3----4--------
         flatten()
-----1--2----3-1--4-2---3--
```
```js
const source = pull.values([
  pull.values([ 1, 2, 3, 4 ]),
  pull.values([ 1, 2, 3 ])
])
const sink = pull.log()
fork icon46
star icon839
watch icon48

+ 7 other calls in file

353
354
355
356
357
358
359
360
361
362
    encryptionFormat: 'box',
  })

startMeasure(t, 'add 1000 box1 msgs')
pull(
  pull.values(opts),
  pull.asyncMap(sbot.db.create),
  pull.collect((err, msgs) => {
    endMeasure(t, 'add 1000 box1 msgs')
    if (err) t.fail(err)
fork icon6
star icon41
watch icon0

+ 3 other calls in file

How does pull-stream.values work?

pull-stream.values is a function in the pull-stream library that creates a readable stream from an array of values. When called, it returns a function that can be used as a source in a pull-stream pipeline, emitting each value in the array in turn to the downstream consumer.

241
242
243
244
245
246
247
248
249
250
function tribeList (opts, cb) {
  if (typeof opts === 'function') return tribeList({}, opts)

  onKeystoreReady(() => {
    pull(
      pull.values(keystore.group.list()),
      paraMap(tribeGet, 4),
      opts.subtribes
        ? null
        : pull.filter(tribe => tribe.parentGroupId === undefined),
fork icon4
star icon27
watch icon16

72
73
74
75
76
77
78
79
80
81
 * @param {array} feedIds - array of feed ids
 */
const getProfilesForIds = (feedIds) => {
  return new Promise((resolve, reject) => {
    pull(
      pull.values(feedIds),
      pullParaMap((feedId, cb) => {
        getProfile(feedId)
          .then(profile => cb(null, profile))
          .catch(cb)
fork icon2
star icon3
watch icon0

+ 5 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
const pull = require("pull-stream");
const values = pull.values([1, 2, 3, 4, 5]);

pull(
  values,
  pull.drain((value) => console.log(value))
);

// Output: 1 2 3 4 5

204
205
206
207
208
209
210
211
212
213
  )
}

function listInvites() {
  return pull(
    pull.values([0]), // dummy value used to kickstart the stream
    pull.asyncMap((n, cb) => {
      ssb.metafeeds.findOrCreate((err, myRoot) => {
        // prettier-ignore
        if (err) return cb(clarify(err, 'Failed to get root metafeed when listing invites'))
fork icon1
star icon7
watch icon4

+ 32 other calls in file

119
120
121
122
123
124
125
126
127
128
const groupId = data.id

//console.time('getTangles')

pull(
  pull.values(publishArray),
  paraMap(
    (value, cb) =>
      server.tribes2.publish(
        { type: 'memo', value, recps: [groupId] },
fork icon1
star icon7
watch icon0

+ 2 other calls in file

134
135
136
137
138
139
140
141
142
143
  })
}

function listGroupIds(opts = {}) {
  return pull(
    pull.values([0]),
    pull.asyncMap((_, cb) => {
      keyringReady.onReady(() => {
        return cb(null, keyring.group.list({ live: !!opts.live }))
      })
fork icon0
star icon5
watch icon4

+ 81 other calls in file

47
48
49
50
51
52
53
54
55
56

var util = require('./util')(ssb)

if (args['graph-easy']) {
  pull(
    pull.values(keys),
    pull.drain(function (k) {
      if (Object.keys(tangle[k]).length > 0) 
        Object.keys(tangle[k]).forEach(function (k2) {
          var label = tangle[k][k2] || 'source'
fork icon0
star icon4
watch icon2

+ 315 other calls in file

482
483
484
485
486
487
488
489
490
491
  )
}

// Get and check all sources
pull(
  pull.values(op.sources),
  pull.asyncMap(get),
  pull.asyncMap((src, cb) => {
    var sId = src.msg.key
    var sOp = src.msg.value.content
fork icon0
star icon4
watch icon2

+ 349 other calls in file

23
24
25
26
27
28
29
30
31
32
if (typeof args['alias-prefix'] !== "string")
  return cb(new Error("Invalid alias-prefix " + args["alias-prefix"] +
                      ", expected a string"))

list = pull(
  pull.values(ids),
  pull.asyncMap(function (id, cb) {
    ssb.about.socialValue(
      { key: 'name', dest: id }, 
      (err, value) => {
fork icon0
star icon4
watch icon2

+ 69 other calls in file

50
51
52
53
54
55
56
57
58
59
  return cb(new Error("Non-unique match, found " +
                      Object.keys(types).length + 
                      " results"))

pull(
  pull.values(types),
  pull.asyncMap(function (tok, cb) {
    ssb.about.socialValue(
      { key: 'name', dest: tok.author}, function (err, name) {
        tok.author = { 
fork icon0
star icon4
watch icon2

+ 69 other calls in file

37
38
39
40
41
42
43
44
45
46
}

function addPipeline (index, addStream, list, wrapWithDirectory) {
  pull(
    zip(
      pull.values(list),
      pull(
        pull.values(list),
        paramap(fs.stat.bind(fs), 50)
      )
fork icon0
star icon3
watch icon3

+ 7 other calls in file

29
30
31
32
33
34
35
36
37
38
  })
}

sv.since.once( ()=>{
  pull(
    pull.values([{
      keys: [1],
      seq: 0,
      value: {foo: 'bar'}
    }]),
fork icon0
star icon1
watch icon0

22
23
24
25
26
27
28
29
30
31
  filterMap
),

pull(
  // send truncated marker for resuming search
  pull.values([marker]),

  // don't emit the resume if we're at the end of the stream
  pull.filter(() => count === limit)
)
fork icon0
star icon0
watch icon1

+ 5 other calls in file

55
56
57
58
59
60
61
62
63
64
self.dialProtocol(peer, '/add_unverified_transaction', function (err, conn) {
    if (err) {
        return
    }
    pull(
        pull.values([JSON.stringify(transaction)]),
        conn
    )

});
fork icon0
star icon0
watch icon2

+ 4 other calls in file

85
86
87
88
89
90
91
92
93
    )
});

self.node.handle('/get_random_transaction', (protocol, conn) => {
    pull(
        pull.values(JSON.stringify(self.get_random_transaction())),
        conn
    )
});
fork icon0
star icon0
watch icon2