I have suggestion about specification of the escape.

T.J. Crowder tj.crowder at farsightsoftware.com
Fri Nov 24 11:48:30 UTC 2017

On Fri, Nov 24, 2017 at 11:38 AM, Renan Bastos <renanbastos.tec at gmail.com>
> Hey guys,
> I communicate that when we go use the escape to object JSON it
> don't escape correctly.
> So I think we should add this suggestion.
> const obj2 = {"name": "NodeJS", "version": "all"};
> console.log(escape(obj)); //%5Bobject%20Object%5D

I don't see any need to do that. `escape(JSON.stringify(obj))` is not
over-long. Small, composable functions are a good thing. And if you want to
define a `escapeAsJSON` function, it's easy to do that in your code.

I do see reasons *not* to do it: We'd have to handle the situation where an
object overrides `toString` and is expecting the string from that, not
JSON, to be used by `escape(obj)`. Handling that would be ugly, it would be
along the lines of "Get `toString` from the object. If `toString` is not
`%ObjProto_toString%`, then..."

-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171124/7859eed1/attachment.html>

More information about the es-discuss mailing list