我正在尝试使用YUI压缩器作为基于socket.io的.js文件(是的,我知道它是服务器端脚本,不需要minification,但它是要求,所以我有一个较少的控制).我的代码是这样的:
- 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);
- });
当我执行YUI压缩器,我得到错误@这行:
- socket.volatile.emit('notification',json);
- [ERROR] 36:22:missing name after . operator
解决方法
如果用引号括起来,压缩机将会丢失保留字
- socket['volatile'].emit()