Missing name after . operator YUI Compressor for socket.io js files

Pradeep Simha picture Pradeep Simha · Oct 7, 2013 · Viewed 9.5k times · Source

I am trying to use YUI compressor for socket.io based .js file (yes, I know it's server side script and doesn't require minfication, but it's requirement so I have a less control). My code is like this:

fs.readFile('../examples/example.xml', function(err, data) {
  if (err) throw err;
  // parsing the new xml data and converting them into json file
  var json = parser.toJson(data);
  // adding the time of the last update
  json.time = new Date();
  // send the new data to the client
  socket.volatile.emit('notification', json);
});

When I execute YUI compressor I get error @ this line:

socket.volatile.emit('notification', json);

[ERROR] 36:22:missing name after . operator

I assume it is throwing error becase volatile is keyword right? Can anyone guide me how to get rid of this error.

Answer

user32225 picture user32225 · Oct 8, 2013

no compressor will mess with reserved words if enclosed in quotes

socket['volatile'].emit()