Closed CIVITAS-John closed 2 years ago
Also, I am not sure if the functional style in this extension could bring up the best performance. We don't need to call a function for each byte.
A very quick change in the compiled js file:
for (var x of bytes) {
if (!(checks.isNumber(x) && (x >= 0) && (x <= 255)))
throw exceptions.extension(`All elements of the list argument to 'encode:${primName}' must be numbers between 0 and 255`);
}
return f(bytes);
What are the "first answer" and "second answer" that you're referring to?
This is how we implemented:
This is the better (and uglier) way:
I have not been able to reproduce this issue with either a 40MB string passed to base64-to-bytes
, nor with a 100MB string passed to string-to-bytes
.
Please include in your report
Hi, the primitive you need to test is bytes-to-base64
, not vice versa.
Please also consider changing the verification to a simple loop (instead of nested functions).
The easiest way is just to convert your 40MB string to bytes and back to base64.
Please refer to the second answer: the current way to implement the function is
btoa(String.fromCharCode(bytes...))
However, when the length of bytes gets too large, it will exceed the call stack limit. Therefore, seems that the first answer provides a better way to implement, and we could fix this issue very easily.