Commit 972b77c21531a8e0c42394380dd3331262f938f9
Use pull.once
Charles Lehner committed on 2/8/2016, 4:37:24 AMParent: b634a730e0a867de83e309323cb2c57c2714d0da
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -27,21 +27,10 @@ | ||
27 | 27 | read(null, next) |
28 | 28 | }) |
29 | 29 | } |
30 | 30 | |
31 | -// return a source that delivers some data and then ends | |
32 | -// TODO: use pull.once and abortCb for this | |
33 | -function endSource(data) { | |
34 | - var done | |
35 | - return function (end, cb) { | |
36 | - if (done) return cb(true) | |
37 | - done = true | |
38 | - cb(null, data) | |
39 | - } | |
40 | -} | |
41 | - | |
42 | 31 | function capabilitiesSource(prefix) { |
43 | - return endSource([ | |
32 | + return pull.once([ | |
44 | 33 | 'option', |
45 | 34 | 'connect', |
46 | 35 | 'refspec refs/heads/*:refs/' + prefix + '/heads/*', |
47 | 36 | 'refspec refs/tags/*:refs/' + prefix + '/tags/*', |
@@ -66,13 +55,13 @@ | ||
66 | 55 | var msg = handleOption(options, args[0], args[1]) |
67 | 56 | msg = (msg === true) ? 'ok' |
68 | 57 | : (msg === false) ? 'unsupported' |
69 | 58 | : 'error ' + msg |
70 | - return endSource(msg + '\n') | |
59 | + return pull.once(msg + '\n') | |
71 | 60 | } |
72 | 61 | |
73 | 62 | function listSource() { |
74 | - return endSource([ | |
63 | + return pull.once([ | |
75 | 64 | /* TODO */ |
76 | 65 | ].join('\n') + '\n\n') |
77 | 66 | } |
78 | 67 |
Built with git-ssb-web