git ssb

3+

cel / ssb-npm-registry



Tree: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3

Files: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3 / node_modules / pull-stream / test / continuable.js

778 bytesRaw
1var pull = require('../pull')
2var count = require('../sources/count')
3var error = require('../sources/error')
4var map = require('../throughs/map')
5var test = require('tape')
6
7test('continuable stream', function (t) {
8 t.plan(2)
9
10 var continuable = function (read) {
11 return function (cb) {
12 read(null, function next (end, data) {
13 if (end === true) return cb(null)
14 if (end) return cb(end)
15 read(end, next)
16 })
17 }
18 }
19
20 // With values:
21 pull(
22 count(5),
23 map(function (item) {
24 return item * 2
25 }),
26 continuable
27 )(function (err) {
28 t.false(err, 'no error')
29 })
30
31 // With error:
32 pull(
33 error(new Error('test error')),
34 continuable
35 )(function (err) {
36 t.is(err.message, 'test error', 'error')
37 })
38})
39

Built with git-ssb-web