MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / transform

Function transform

MathBox/mathbox-bundle.js:38004–38023  ·  view source on GitHub ↗

* An alternative to `_.reduce` this method transforms `object` to a new * `accumulator` object which is the result of running each of its own * enumerable properties through a callback, with each callback execution * potentially mutating the `accumulator` object. The callback is bound

(object, callback, accumulator, thisArg)

Source from the content-addressed store, hash-verified

38002 * // => { 'a': 3, 'b': 6, 'c': 9 }
38003 */
38004 function transform(object, callback, accumulator, thisArg) {
38005 var isArr = isArray(object);
38006 if (accumulator == null) {
38007 if (isArr) {
38008 accumulator = [];
38009 } else {
38010 var ctor = object && object.constructor,
38011 proto = ctor && ctor.prototype;
38012
38013 accumulator = baseCreate(proto);
38014 }
38015 }
38016 if (callback) {
38017 callback = lodash.createCallback(callback, thisArg, 4);
38018 (isArr ? forEach : forOwn)(object, function(value, index, object) {
38019 return callback(accumulator, value, index, object);
38020 });
38021 }
38022 return accumulator;
38023 }
38024
38025 /**
38026 * Creates an array composed of the own enumerable property values of `object`.

Callers

nothing calls this directly

Calls 3

baseCreateFunction · 0.85
isArrayFunction · 0.70
callbackFunction · 0.70

Tested by

no test coverage detected