Skip to content
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

[FEATURE] some should-be-array fields are not guaranteed to be an array #21

Open
myrne opened this issue Apr 29, 2013 · 6 comments
Open
Labels

Comments

@myrne
Copy link
Contributor

myrne commented Apr 29, 2013

Not guaranteed to be array: keywords, contributors, authors, man.
Guaranteed to be array (if set): files

@myrne
Copy link
Contributor Author

myrne commented Apr 29, 2013

This is problematic when people call array functions on it. forEach, join, etc.

@myrne
Copy link
Contributor Author

myrne commented May 2, 2013

@isaacs Are you ok with setting data.keywords to an empty array if it's anything else than a string (will be split) or an array (left alone)? I see no downsides.

@myrne
Copy link
Contributor Author

myrne commented May 2, 2013

Same applies for data.man.

@myrne
Copy link
Contributor Author

myrne commented May 2, 2013

Or maybe, rather than setting it to empty array, simply delete the property.
For example, data.files is currently deleted if it exists and is not an array.

@myrne
Copy link
Contributor Author

myrne commented May 2, 2013

The "people" fields (data.contributors and data.authors) are currently left alone if not an array.

@myrne
Copy link
Contributor Author

myrne commented May 2, 2013

In general, there's a trade-off between "API simplicity" (i.e. does a consumer need to do .isArray() first?) and maintaining any ("malformed") data that's there.

I think a choice should be made. Either all fields get the same treatment, or some fields are excepted due to some kind of special status.

@darcyclarke darcyclarke changed the title some should-be-array fields are not guaranteed to be an array [FEATURE] some should-be-array fields are not guaranteed to be an array Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants