git ssb

3+

cel / ssb-npm-registry



Tree: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3

Files: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3 / node_modules / stream-to-pull-stream / test / sink.js

917 bytesRaw
1var pull = require('pull-stream')
2var through = require('through')
3var toPull = require('../')
4
5var tape = require('tape')
6
7tape('propagate close back to source', function (t) {
8
9// t.plan(4)
10
11 var ended = false
12 var input = [1,2,3]
13 var ts = through(function (data) {
14 t.equal(data, input.shift())
15 }, function () {
16 ended = true
17 this.queue(null)
18 })
19
20 pull(
21 pull.values([1,2,3]),
22 toPull.sink(ts, function (err) {
23 t.notOk(err)
24 t.ok(ended)
25 t.end()
26 })
27 )
28})
29
30
31tape('error', function (t) {
32
33
34 var ts = through()
35 var err = new Error('wtf')
36 pull(
37 pull.values([1,2,3]),
38 function (read) {
39 return function (abort, cb) {
40 read(abort, function (end, data) {
41 if(data === 3) cb(err)
42 else cb(end, data)
43 })
44 }
45 },
46 toPull.sink(ts, function (_err) {
47 t.equal(_err, err)
48 t.end()
49 })
50 )
51
52})
53

Built with git-ssb-web