Closed agbianchessi closed 4 years ago
Possible fix:
diff --git a/lib/binary_parser.ts b/lib/binary_parser.ts
index f037691..6d77392 100644
--- a/lib/binary_parser.ts
+++ b/lib/binary_parser.ts
@@ -651,7 +651,14 @@ export class Parser {
}
compile() {
- this.compiled = new Function('buffer', 'constructorFn', this.getCode());
+ this.compiled = new Function(
+ 'TextDecoder',
+ `return function (buffer, constructorFn) { ${this.getCode()} };`
+ )(
+ typeof TextDecoder === 'undefined'
+ ? require('util').TextDecoder
+ : TextDecoder
+ );
}
sizeOf(): number {
UP! I have the same problem. It is not ok that you broke package on the old version too. I tried to reinstall more old version like 1.3.2 or 1.4.0 and I have the same problem with "TextDecoder is not defined". I use v10 node. Fix please, because all was worked on 1.4.0 binary parser.
I am running nodejs version 10. TextDecoder has been added to global after v11: Globals/TextDecoder...
I suggest you either to change the code to make it more compatible to older nodejs or to document the minimal nodejs version (>= 11.0)...
I have the same problem and you can decide this by use more older version binary-parser, like 1.4.0 And remove "^" from package.json, because their new minor version broke our applications :)
Sorry about this, I've opened a PR based on @mohd-akram's patch that should fix this issue.
This should have been fixed in v1.6.2. Let me know if the problem still exists.
I am running nodejs version 10. TextDecoder has been added to global after v11: Globals/TextDecoder...
I suggest you either to change the code to make it more compatible to older nodejs or to document the minimal nodejs version (>= 11.0)...