Ensure _.flatten works with _.map in underscore builds.

This commit is contained in:
John-David Dalton
2014-01-20 11:33:31 -08:00
parent ca58bab1f0
commit 58ce97c0b4
2 changed files with 28 additions and 23 deletions

View File

@@ -1179,7 +1179,11 @@
* _.flatten(characters, 'pets');
* // => ['hoppy', 'baby puss', 'dino']
*/
function flatten(array, isShallow) {
function flatten(array, isShallow, guard) {
var type = typeof isShallow;
if ((type == 'number' || type == 'string') && guard && guard[isShallow] === array) {
isShallow = false;
}
return baseFlatten(array, isShallow);
}