marcello3d / node-tosource

Converts JavaScript objects to source

Home Page:https://github.com/marcello3d/node-tosource

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make a polyfill

piranna opened this issue · comments

Split the code in several functions and set it to the prototype object of the diferent classes to polyfill the functionality that Firefox offer. The current tosource() could still be exported to be backwards compatible, only that internally would call the per-object functions.

It's an interesting idea, but because Firefox's toSource() is not a standard, we can't polyfill without introducing incompatibility risk.

That's just my opinion.

Why not make a new project (tosource-polyfill?) that uses this module (or fork it) and checks for Firefox's toSource? Then you can use either approach.

I think there would not be incompatibilities if we follow how Firefox works, and also the actual output of this project seems to be just the same as it does, so I don't believe there would be incompatibilites. I'll try to do a pull-request so you can inspect it.

Since it's not a standard, though, Firefox could change their format at any time. Or another browser could release an incompatible version. Or toSource could become part of some future standard JavaScript, but in a completely different format.

Source code will not change ;-) Also I'm currently detecting for native support, so it will not be a problem :-) Only stopper I'm having is regarding to seen and indent, but other things seems flawlessly. i'll see what I can do here.