Commit bb1bdb89523248804aace29fa3128944c6b432c3
export pull() as default
Dominic Tarr committed on 6/9/2013, 10:51:08 AMParent: ed03e36a93497fb87f78c4ab0933a1e1531ffd62
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -1,10 +1,28 @@ | ||
1 | - | |
2 | 1 | var sources = require('./sources') |
3 | 2 | var sinks = require('./sinks') |
4 | 3 | var throughs = require('./throughs') |
5 | 4 | var u = require('pull-core') |
6 | 5 | |
6 | +function isThrough (fun) { | |
7 | + return fun.type === "Through" || fun.length === 1 | |
8 | +} | |
9 | + | |
10 | +var exports = module.exports = function pull () { | |
11 | + var args = [].slice.call(arguments) | |
12 | + | |
13 | + if(isThrough(args[0])) | |
14 | + return function (read) { | |
15 | + args.unshift(read) | |
16 | + return pull.apply(null, args) | |
17 | + } | |
18 | + | |
19 | + var read = args.shift() | |
20 | + while(args.length) | |
21 | + read = args.shift() (read) | |
22 | + return read | |
23 | +} | |
24 | + | |
7 | 25 | for(var k in sources) |
8 | 26 | exports[k] = u.Source(sources[k]) |
9 | 27 | |
10 | 28 | for(var k in throughs) |
Built with git-ssb-web