(fn, that, length)
| 123 | } |
| 124 | // Optional / simple context binding |
| 125 | function ctx(fn, that, length){ |
| 126 | assertFunction(fn); |
| 127 | if(~length && that === undefined)return fn; |
| 128 | switch(length){ |
| 129 | case 1: return function(a){ |
| 130 | return fn.call(that, a); |
| 131 | }; |
| 132 | case 2: return function(a, b){ |
| 133 | return fn.call(that, a, b); |
| 134 | }; |
| 135 | case 3: return function(a, b, c){ |
| 136 | return fn.call(that, a, b, c); |
| 137 | } |
| 138 | } return function(/* ...args */){ |
| 139 | return fn.apply(that, arguments); |
| 140 | } |
| 141 | } |
| 142 | // Fast apply |
| 143 | // http://jsperf.lnkit.com/fast-apply/5 |
| 144 | function invoke(fn, args, that){ |
no test coverage detected