(func, startIndex)
| 62 | // argument length (or an explicit `startIndex`), into an array that becomes |
| 63 | // the last argument. Similar to ES6’s "rest parameter". |
| 64 | function restArguments(func, startIndex) { |
| 65 | startIndex = startIndex == null ? func.length - 1 : +startIndex; |
| 66 | return function() { |
| 67 | var length = Math.max(arguments.length - startIndex, 0), |
| 68 | rest = Array(length), |
| 69 | index = 0; |
| 70 | for (; index < length; index++) { |
| 71 | rest[index] = arguments[index + startIndex]; |
| 72 | } |
| 73 | switch (startIndex) { |
| 74 | case 0: return func.call(this, rest); |
| 75 | case 1: return func.call(this, arguments[0], rest); |
| 76 | case 2: return func.call(this, arguments[0], arguments[1], rest); |
| 77 | } |
| 78 | var args = Array(startIndex + 1); |
| 79 | for (index = 0; index < startIndex; index++) { |
| 80 | args[index] = arguments[index]; |
| 81 | } |
| 82 | args[startIndex] = rest; |
| 83 | return func.apply(this, args); |
| 84 | }; |
| 85 | } |
| 86 | |
| 87 | // Is a given variable an object? |
| 88 | function isObject(obj) { |
no outgoing calls
no test coverage detected
searching dependent graphs…