[英]SyntaxError: missing ) after argument list while using LZMA-js
I am trying to compress a string using the LZMA-JS library found here . 我正在尝试使用此处找到的LZMA-JS库压缩字符串。 Here is my javascript:
这是我的JavaScript:
var reader = new FileReader();
reader.addEventListener("load", function () {
var big_code = reader.result;
console.log(big_code.length);
var my_lzma = new LZMA();
my_lzma.compress(my_lzma, 1, on_finish(result, error) {
code = result;
});
console.log(code.length);
}, false);
The error occurs on this line 该行发生错误
my_lzma.compress(my_lzma, 1, on_finish(result, error) { //the rest occurs below
However, when I change this line by removing the {}
brackets like this 但是,当我通过像这样删除
{}
括号来更改此行时
my_lzma.compress(my_lzma, 1, on_finish(result, error));
the error goes away. 错误消失了。 Unfortunately this makes the code useless because I need the
result
. 不幸的是,这使代码无用,因为我需要
result
。
I have looked around the internet for over an hour trying to find a solution to this error. 我在互联网上看了一个多小时,试图找到解决此错误的方法。 I don't believe this is a duplicate because I have not found anything related.
我不相信这是重复的,因为我没有发现任何相关的东西。
Why am I getting this error? 为什么会出现此错误?
The documentation is perhaps confusing - the function's role, not name, is on_finish
, so use this instead to indicate you are creating an in-line function: 该文档可能令人困惑-函数的角色(而不是名称)是
on_finish
,因此请改用它来表明您正在创建内联函数:
my_lzma.compress(my_lzma, 1, function (result, error) {
code = result;
});
See the example usage here . 请参阅此处的示例用法 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.