MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / _restParam

Function _restParam

public/javascripts/async.js:157–177  ·  view source on GitHub ↗
(func, startIndex)

Source from the content-addressed store, hash-verified

155 // This accumulates the arguments passed into an array, after a given index.
156 // From underscore.js (https://github.com/jashkenas/underscore/pull/2140).
157 function _restParam(func, startIndex) {
158 startIndex = startIndex == null ? func.length - 1 : +startIndex;
159 return function() {
160 var length = Math.max(arguments.length - startIndex, 0);
161 var rest = Array(length);
162 for (var index = 0; index < length; index++) {
163 rest[index] = arguments[index + startIndex];
164 }
165 switch (startIndex) {
166 case 0: return func.call(this, rest);
167 case 1: return func.call(this, arguments[0], rest);
168 }
169 // Currently unused but handle cases outside of the switch statement:
170 // var args = Array(startIndex + 1);
171 // for (index = 0; index < startIndex; index++) {
172 // args[index] = arguments[index];
173 // }
174 // args[startIndex] = rest;
175 // return func.apply(this, args);
176 };
177 }
178
179 function _withoutIndex(iterator) {
180 return function (value, index, callback) {

Callers 6

async.jsFile · 0.85
wrapIteratorFunction · 0.85
_parallelFunction · 0.85
_console_fnFunction · 0.85
_applyEachFunction · 0.85
ensureAsyncFunction · 0.85

Calls 1

callMethod · 0.80

Tested by

no test coverage detected