MCPcopy
hub / github.com/jashkenas/underscore / restArguments

Function restArguments

underscore-node-f.cjs:57–78  ·  view source on GitHub ↗
(func, startIndex)

Source from the content-addressed store, hash-verified

55// argument length (or an explicit `startIndex`), into an array that becomes
56// the last argument. Similar to ES6’s "rest parameter".
57function restArguments(func, startIndex) {
58 startIndex = startIndex == null ? func.length - 1 : +startIndex;
59 return function() {
60 var length = Math.max(arguments.length - startIndex, 0),
61 rest = Array(length),
62 index = 0;
63 for (; index < length; index++) {
64 rest[index] = arguments[index + startIndex];
65 }
66 switch (startIndex) {
67 case 0: return func.call(this, rest);
68 case 1: return func.call(this, arguments[0], rest);
69 case 2: return func.call(this, arguments[0], arguments[1], rest);
70 }
71 var args = Array(startIndex + 1);
72 for (index = 0; index < startIndex; index++) {
73 args[index] = arguments[index];
74 }
75 args[startIndex] = rest;
76 return func.apply(this, args);
77 };
78}
79
80// Is a given variable an object?
81function isObject(obj) {

Callers 2

debounceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…