* 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)
| 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 |
no test coverage detected