MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / flatten

Function flatten

MathBox/mathbox-bundle.js:39496–39507  ·  view source on GitHub ↗

* Flattens a nested array (the nesting can be to any depth). If `isShallow` * is truey, the array will only be flattened a single level. If a callback * is provided each element of the array is passed through the callback before * flattening. The callback is bound to `thisArg` and inv

(array, isShallow, callback, thisArg)

Source from the content-addressed store, hash-verified

39494 * // => ['hoppy', 'baby puss', 'dino']
39495 */
39496 function flatten(array, isShallow, callback, thisArg) {
39497 // juggle arguments
39498 if (typeof isShallow != 'boolean' && isShallow != null) {
39499 thisArg = callback;
39500 callback = (typeof isShallow != 'function' && thisArg && thisArg[isShallow] === array) ? null : isShallow;
39501 isShallow = false;
39502 }
39503 if (callback != null) {
39504 array = map(array, callback, thisArg);
39505 }
39506 return baseFlatten(array, isShallow);
39507 }
39508
39509 /**
39510 * Gets the index at which the first occurrence of `value` is found using

Callers 2

mathbox-core.jsFile · 0.70
mathbox-bundle.jsFile · 0.70

Calls 2

baseFlattenFunction · 0.85
mapFunction · 0.70

Tested by

no test coverage detected