MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / last

Function last

MathBox/mathbox-bundle.js:39724–39741  ·  view source on GitHub ↗

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

(array, callback, thisArg)

Source from the content-addressed store, hash-verified

39722 * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
39723 */
39724 function last(array, callback, thisArg) {
39725 var n = 0,
39726 length = array ? array.length : 0;
39727
39728 if (typeof callback != 'number' && callback != null) {
39729 var index = length;
39730 callback = lodash.createCallback(callback, thisArg, 3);
39731 while (index-- && callback(array[index], index, array)) {
39732 n++;
39733 }
39734 } else {
39735 n = callback;
39736 if (n == null || thisArg) {
39737 return array ? array[length - 1] : undefined;
39738 }
39739 }
39740 return slice(array, nativeMax(0, length - n));
39741 }
39742
39743 /**
39744 * Gets the index at which the last occurrence of `value` is found using strict

Callers 2

mathbox-core.jsFile · 0.85
mathbox-bundle.jsFile · 0.85

Calls 2

sliceFunction · 0.85
callbackFunction · 0.70

Tested by

no test coverage detected