-
Notifications
You must be signed in to change notification settings - Fork 7.1k
underscore-like behaviour of flatten #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It's a feature and more consistent as other "Array" category methods like Underscore's |
Did you run into an issue in your code where you expected an empty array? |
yes, after drop-in replacement I found that this code fails because match returns array or null. var result = _.flatten(string.match(/regexp/))[0] //result or undefined, but not throw Error; I understand that this is not best idea to use _.flatten in this way, but anyway. In this commits I missed that underscore also flattens objects: _.flatten({'a': 1}); //[1] I can do it in this PR if you want. |
underscore flatten( _.flatten({'a': [1, 2, [3]], 'b': [1,[4],10]}); // [1,2,3,1,4,10] lodash flatten ( _.flatten({'a': [1, 2, [3]], 'b': [1,[4],10]}); // [] |
Naw, no need. The flattening of objects is undocumented/untested and an unintended side effect of Underscore's |
The I will close this for now, but will consider adding a fail safe to all "Arrays" methods. |
Resolved by 0a2e5fd2. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I don't sure it is bug or a feature.