RangeError: Invalid string length
See original GitHub issueNice idea, but for some reason it doesn’t want to work out of the box.
This example:
const bytenode = require('bytenode');
let helloWorldBytecode = bytenode.compileCode(`console.log('Hi there')`)
bytenode.runBytecode(helloWorldBytecode);
Produce
let dummyCode = ' '.repeat(length);
^
RangeError: Invalid string length
let length = bytecodeBuffer.slice(8, 12).reduce((sum, number, power) => sum += number * 256 ** power, 0);
let dummyCode = ' '.repeat(length); // length is too big
I wonder, what’s the magic behind this line?
Node version: v8.9.3, Mac
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Uncaught RangeError: Invalid string length when appending ...
Your 2-D array accesses are incorrect, but the main problem is that you're re-using the variable i in an inner loop: for (i...
Read more >RangeError: Invalid string length with large files. · Issue #35973
When i'm trying to read a large Json File (700MB - 26.640.222 lines) using ReadStream i'm getting the error: "RangeError: Invalid string length" ......
Read more >RangeError: invalid array length - JavaScript - MDN Web Docs
The JavaScript exception "Invalid array length" occurs when specifying an array length that is either negative, a floating number or exceeds ...
Read more >HTML : Uncaught RangeError: Invalid string length ... - YouTube
HTML : Uncaught RangeError : Invalid string length when appending to a string in JavaScript [ Beautify Your Computer ...
Read more >Simplest solution to JSON.stringify RangeError: Invalid string ...
We often come across this issue where the object or value passed to JSON.stringify is more than it can handle and the most...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, wherever you can use Node.js
require
function, you can use bytenode. Just dorequire('bytenode')
somewhere in your code, after that you can require your ‘.jsc’ files as usual.But of course you can’t use ‘.jsc’ as
src
attribute in<script>
tags.So, this would work:
but this will NOT work:
Awesome and amazing work on this package - Looking forward to put it into good use
JSYK whenever I try to bytenode an obfuscated file using JavaScriptObfuscator I get the same rangeError invalid string length exception
Would be awesome if we can somehow resolve this - would add more security whenever the .js file will exist prior to .jsc on production environment ( prior to compilation / deletion of file )
Then on my electron main.js
Remove javascript obfuscation and it works like a charm