Commit 822a78b0de9a399dae39ef6b8c6142cc908a3ee1
make pull as compose way faster
Dominic Tarr committed on 3/23/2016, 12:02:14 AMParent: 3d39bb95880efe1bb2e347c6e2565ca156ce5996
Files changed
pull.js | changed |
pull.js | ||
---|---|---|
@@ -1,22 +1,23 @@ | ||
1 | 1 | module.exports = function pull (a) { |
2 | + var length = arguments.length | |
2 | 3 | if (typeof a === 'function' && a.length === 1) { |
3 | - var args = [].slice.call(arguments) | |
4 | + var args = new Array(length) | |
5 | + for(var i = 0; i < length; i++) | |
6 | + args[i] = arguments[i] | |
4 | 7 | return function (read) { |
5 | 8 | args.unshift(read) |
6 | 9 | return pull.apply(null, args) |
7 | 10 | } |
8 | 11 | } |
9 | 12 | |
10 | 13 | var read = a |
11 | - var n = arguments.length | |
12 | - var i = 1 | |
13 | 14 | |
14 | 15 | if (read && typeof read.source === 'function') { |
15 | 16 | read = read.source |
16 | 17 | } |
17 | 18 | |
18 | - for (; i < n; i++) { | |
19 | + for (var i = 1; i < length; i++) { | |
19 | 20 | var s = arguments[i] |
20 | 21 | if (typeof s === 'function') { |
21 | 22 | read = s(read) |
22 | 23 | } else if (s && typeof s === 'object') { |
@@ -27,4 +28,8 @@ | ||
27 | 28 | |
28 | 29 | return read |
29 | 30 | } |
30 | 31 | |
32 | + | |
33 | + | |
34 | + | |
35 | + |
Built with git-ssb-web