Uh oh!
There was an error while loading. Please reload this page.
fix(view): dont unwrap arrays in json mode - #7506
Conversation
986ac2a to
0be70c4CompareThe 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
d3ec5b5Compareno statistically significant performance changes detected timing results
|
wraithgar
commented
May 11, 2024
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"
] |
ljharb
commented
May 11, 2024
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