-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix(view): dont unwrap arrays in json mode #7506
Conversation
986ac2a
to
0be70c4
Compare
The view command alters the data by default to unwrap single item arrays when in human readable mode (the default). This change makes it so those arrays are not altered when the --json flag is set. Fixes #3611
0be70c4
to
d3ec5b5
Compare
no statistically significant performance changes detected timing results
|
This feels like one of those incorrect behaviors folks have undoubtedly come to rely on, and this would be a breaking change. |
I'm not so sure, because currently this behavior is impossible to predict unless you know the data being returned. In the case of # before
❯ npm view abbrev versions --json
[
"1.0.3",
"1.0.4",
"1.0.5",
"1.0.6",
"1.0.7",
"1.0.9",
"1.1.0",
"1.1.1",
"2.0.0"
]
# after
❯ npmlocal view abbrev versions --json
[
"1.0.3",
"1.0.4",
"1.0.5",
"1.0.6",
"1.0.7",
"1.0.9",
"1.1.0",
"1.1.1",
"2.0.0"
] |
If they did the smart thing and always wrapped the field in [].concat() then this wouldn’t break them, at least :-) |
The view command alters the data by default to unwrap single item arrays
when in human readable mode (the default). This change makes it so those
arrays are not altered when the --json flag is set.
Fixes #3611