之后缺少名字.运算符YUI Compressor for socket.io js文件

Pra*_*mha 15 javascript yui minify socket.io

我试图使用YUI压缩器的socket.io基于.js文件(是的,我知道它的服务器端脚本,不需要minfication,但它的要求所以我有一个较少的控制).我的代码是这样的:

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);
});
Run Code Online (Sandbox Code Playgroud)

当我执行YUI压缩器时,我得到错误@这一行:

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

[ERROR] 36:22:missing name after . operator
Run Code Online (Sandbox Code Playgroud)

我认为它是抛出错误因为volatile是关键字对吗?任何人都可以指导我如何摆脱这个错误.

小智 23

如果用引号括起来,没有压缩器会乱用保留字

socket['volatile'].emit() 
Run Code Online (Sandbox Code Playgroud)