-
Notifications
You must be signed in to change notification settings - Fork 30k
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
docs: add info about serializable types for querystring.stringify()
#12313
docs: add info about serializable types for querystring.stringify()
#12313
Conversation
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a typo. Maybe it would be good to mention what happens for other input, though?
doc/api/querystring.md
Outdated
@@ -101,6 +101,9 @@ added: v0.1.25 | |||
The `querystring.stringify()` method produces a URL query string from a | |||
given `obj` by iterating through the object's "own properties". | |||
|
|||
This method searializes the following types of values passed in `obj`: strings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: serializes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I'll fix the typo.
I'm not sure if I understand it correctly but from what I understood from the linked source code was that an empty string is returned if the param passed if not of the aforementioned types. So should I mention this implementation detail? Not sure how to frame it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but from what I understood from the linked source code was that an empty string is returned if the param passed if not of the aforementioned types.
That’s how I read the stringify
source code, too. How about adding something like Any other input values will be coerced to empty strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
Fix typo. Add what happens when another data type is passed to `querystring.stringify()` besides the ones that can be correctly parsed
doc/api/querystring.md
Outdated
@@ -101,6 +101,10 @@ added: v0.1.25 | |||
The `querystring.stringify()` method produces a URL query string from a | |||
given `obj` by iterating through the object's "own properties". | |||
|
|||
This method serializes the following types of values passed in `obj`: strings, | |||
finite numbers, booleans and arrays of the aforementioned types. | |||
Any other input values will be coerced to empty strings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is better to use the period
(I'm sorry if I'm wrong because I am not native).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, thanks for pointing it out :)
doc/api/querystring.md
Outdated
@@ -101,6 +101,10 @@ added: v0.1.25 | |||
The `querystring.stringify()` method produces a URL query string from a | |||
given `obj` by iterating through the object's "own properties". | |||
|
|||
This method serializes the following types of values passed in `obj`: strings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this paragragh can be added to the type annotation of obj
above? Using the {Type}
syntax would give us links to MDN documentations. Something like
Values should be {String|Number|Boolean|String[]|Number[]|Boolean[]}
(more explanations)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to ignore, but I would just drop the This method
at the front :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joyeecheung, this is neat -- I didn't know this!
@jasnell, dropped :)
doc/api/querystring.md
Outdated
@@ -101,6 +101,10 @@ added: v0.1.25 | |||
The `querystring.stringify()` method produces a URL query string from a | |||
given `obj` by iterating through the object's "own properties". | |||
|
|||
This method serializes the following types of values passed in `obj`: strings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to ignore, but I would just drop the This method
at the front :-)
@@ -101,6 +101,10 @@ added: v0.1.25 | |||
The `querystring.stringify()` method produces a URL query string from a | |||
given `obj` by iterating through the object's "own properties". | |||
|
|||
It serializes the following types of values passed in `obj`: | |||
{String|Number|Boolean|String[]|Number[]|Boolean[]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: if I'm not wrong primitive types should be in lowercase.
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs. Add what happens when another data type is passed to `querystring.stringify()` besides the ones that can be correctly parsed PR-URL: nodejs#12313 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs. Add what happens when another data type is passed to `querystring.stringify()` besides the ones that can be correctly parsed PR-URL: #12313 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs. Add what happens when another data type is passed to `querystring.stringify()` besides the ones that can be correctly parsed PR-URL: #12313 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs. Add what happens when another data type is passed to `querystring.stringify()` besides the ones that can be correctly parsed PR-URL: #12313 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs. Add what happens when another data type is passed to `querystring.stringify()` besides the ones that can be correctly parsed PR-URL: #12313 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs. Add what happens when another data type is passed to `querystring.stringify()` besides the ones that can be correctly parsed PR-URL: #12313 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs. Add what happens when another data type is passed to `querystring.stringify()` besides the ones that can be correctly parsed PR-URL: nodejs/node#12313 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
querystring.stringify() doesn't serialize some values. Explicitly mention what values are serialized in the docs.
Fixes #12234
Checklist
Affected core subsystem(s)
doc