lovell/media-type

Rename MediaType.prototype.asString to MediaType.prototype.toString

moll opened this issue · 2 comments

moll commented

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

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 commented

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.