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

Rename MediaType.prototype.asString to MediaType.prototype.toString #3

Open
moll opened this issue Oct 15, 2014 · 2 comments
Open

Rename MediaType.prototype.asString to MediaType.prototype.toString #3

moll opened this issue Oct 15, 2014 · 2 comments

Comments

@moll
Copy link

moll commented Oct 15, 2014

JavaScript invokes toString when converting an object to a string. If you'd rename the current asString to toString, this would follow that convention.

Cheers

@lovell
Copy link
Owner

lovell commented Oct 15, 2014

Hi Andri, #2 provides the original reasoning behind the use of an explicit asString vs implicit toString.

IIRC, if Node.js' console.dir allowed the use of custom inspect methods this wouldn't be a problem.

Are you aware of a better solution?

@moll
Copy link
Author

moll commented Oct 15, 2014

Well, I'd say API global consistency and conventions are most important and debug workarounds are second to that. In JavaScript that would be toString (and toJSON and parse, but that for another day ;-).

If console.dir stringifies an object with toString, then that its problem and should be fixed there. Skimming only the code of console.dir and util.inspect didn't seem to hint that, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants