MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / map

Function map

MathBox/mathbox-bundle.js:38634–38651  ·  view source on GitHub ↗

* Creates an array of values by running each element in the collection * through the callback. The callback is bound to `thisArg` and invoked with * three arguments; (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style

(collection, callback, thisArg)

Source from the content-addressed store, hash-verified

38632 * // => ['barney', 'fred']
38633 */
38634 function map(collection, callback, thisArg) {
38635 var index = -1,
38636 length = collection ? collection.length : 0;
38637
38638 callback = lodash.createCallback(callback, thisArg, 3);
38639 if (typeof length == 'number') {
38640 var result = Array(length);
38641 while (++index < length) {
38642 result[index] = callback(collection[index], index, collection);
38643 }
38644 } else {
38645 result = [];
38646 forOwn(collection, function(value, key, collection) {
38647 result[++index] = callback(value, key, collection);
38648 });
38649 }
38650 return result;
38651 }
38652
38653 /**
38654 * Retrieves the maximum value of a collection. If the collection is empty or

Callers 3

sortByFunction · 0.70
flattenFunction · 0.70
mathbox-bundle.jsFile · 0.70

Calls 2

forOwnFunction · 0.85
callbackFunction · 0.70

Tested by

no test coverage detected