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

你。 提交于 2019-12-23 06:56:56

问题


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.


回答1:


no compressor will mess with reserved words if enclosed in quotes

socket['volatile'].emit() 


来源:https://stackoverflow.com/questions/19217365/missing-name-after-operator-yui-compressor-for-socket-io-js-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!