You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
There seems to be inconsistencies and unpredictable behaviours within stringify().
You can currently pass an array of objects, but it will throw an error if no columns option is passed, which is weird, since the options object is always optional. And the stringify()output changes with headers and columns options depending on the data type:
constarrayData=[["bar"],["barz"]];constobjectData=[{foo: "bar1"},{foo: "bar2"}]stringify(arrayData)// works as expectedstringify(objectData)// throws errorstringify(arrayData,{headers: true})// adds empty header?stringify(objectData,{headers: true})// throws errorstringify(arrayData,{columns: ["foo"]})// throws errorstringify(objectData,{columns: ["foo"]})// adds header without header: true ?!stringify(arrayData,{columns: ["foo"],headers: true})// throws errorstringify(objectData,{columns: ["foo"],header: true})// the same behaviour as without setting a header:true ?!?stringify(objectData,{columns: ["foo"],header: false})// explicit headers: false removes headers
Describe the solution you'd like
I think we should drop support for object arrays and let the user prepare the data to avoid these inconsistencies. headers option can be removed and columns renamed to headers. If headers is present in options, it adds the header names, else no headers are added.
This means just one more line for the user to map over the objects. But the code is also more clear in what is going on:
constobjectData=[{foo: "bar"},{foo: "barz"}]constpreparedData=objectData.map(object=>[object.foo])stringify(preparedData)// no headers addedstringify(preparedData,{headers: ["foo"]})// adds header
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
There seems to be inconsistencies and unpredictable behaviours within
stringify()
.You can currently pass an array of objects, but it will throw an error if no
columns
option is passed, which is weird, since the options object is always optional. And thestringify()
output changes withheaders
andcolumns
options depending on the data type:Describe the solution you'd like
I think we should drop support for object arrays and let the user prepare the data to avoid these inconsistencies.
headers
option can be removed andcolumns
renamed toheaders
. Ifheaders
is present in options, it adds the header names, else no headers are added.This means just one more line for the user to map over the objects. But the code is also more clear in what is going on:
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: