MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / initial

Function initial

MathBox/mathbox-bundle.js:39594–39608  ·  view source on GitHub ↗

* Gets all but the last element or last `n` elements of an array. If a * callback is provided elements at the end of the array are excluded from * the result as long as the callback returns truey. The callback is bound * to `thisArg` and invoked with three arguments; (value, index, ar

(array, callback, thisArg)

Source from the content-addressed store, hash-verified

39592 * // => ['barney', 'fred']
39593 */
39594 function initial(array, callback, thisArg) {
39595 var n = 0,
39596 length = array ? array.length : 0;
39597
39598 if (typeof callback != 'number' && callback != null) {
39599 var index = length;
39600 callback = lodash.createCallback(callback, thisArg, 3);
39601 while (index-- && callback(array[index], index, array)) {
39602 n++;
39603 }
39604 } else {
39605 n = (callback == null || thisArg) ? 1 : callback || n;
39606 }
39607 return slice(array, 0, nativeMin(nativeMax(0, length - n), length));
39608 }
39609
39610 /**
39611 * Creates an array of unique values present in all provided arrays using

Callers

nothing calls this directly

Calls 2

sliceFunction · 0.85
callbackFunction · 0.70

Tested by

no test coverage detected