I have a large code base with a ton declared like this:
var x = 1,
y = {
},
z = function(arg) {
};
I would like to run a node script to convert it all to
var x = 1;
var y = {
};
var z = function(arg) {
};
It's not as simple as running a regular expression on it, because as soon as an object or function appears, you can no longer search for commas and semicolons.
Is there an existing library or tool that can do this conversion for me? Without trying to minimize or guess the code, I just want to modify the existing, human-readable code to get rid of the comma-separated var declarations.
source
share