You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
700 B
33 lines
700 B
5 years ago
|
var pull = require('pull-stream/pull')
|
||
|
var Cat = require('pull-cat')
|
||
|
var Once = require('pull-stream/sources/once')
|
||
|
|
||
|
module.exports = function (createSource, createLive) {
|
||
|
|
||
|
return function (opts) {
|
||
|
opts = opts || {}
|
||
|
var isOld = opts.old !== false
|
||
|
var isLive = opts.live === true || opts.old === false
|
||
|
|
||
|
if(!isLive && !isOld)
|
||
|
throw new Error('ls with neither old or new is empty')
|
||
|
|
||
|
if(isLive && isOld)
|
||
|
return Cat([
|
||
|
createSource(opts),
|
||
|
opts.sync === false ? null : Once({sync: true}),
|
||
|
createLive(opts)
|
||
|
])
|
||
|
else if(!isLive)
|
||
|
return createSource(opts)
|
||
|
else
|
||
|
return createLive(opts)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|