javascript – 缺少名字.用于socket.io js文件的运算符YUI Compressor

前端之家收集整理的这篇文章主要介绍了javascript – 缺少名字.用于socket.io js文件的运算符YUI Compressor前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用YUI压缩器作为基于socket.io的.js文件(是的,我知道它是服务器端脚本,不需要minification,但它是要求,所以我有一个较少的控制).我的代码是这样的:
  1. fs.readFile('../examples/example.xml',function(err,data) {
  2. if (err) throw err;
  3. // parsing the new xml data and converting them into json file
  4. var json = parser.toJson(data);
  5. // adding the time of the last update
  6. json.time = new Date();
  7. // send the new data to the client
  8. socket.volatile.emit('notification',json);
  9. });

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

  1. socket.volatile.emit('notification',json);
  2.  
  3. [ERROR] 36:22:missing name after . operator

我假设是扔错误,因为volatile是关键字权利?任何人都可以指导我如何摆脱这个错误.

解决方法

如果用引号括起来,压缩机将会丢失保留字
  1. socket['volatile'].emit()

猜你在找的JavaScript相关文章