Updated a range of operations to use ArrayBuffers instead of byteArrays to improve performance with large files.

This commit is contained in:
n1474335 2019-07-29 17:09:46 +01:00
parent 3a8b362dfd
commit 0e95ad8ed6
37 changed files with 112 additions and 84 deletions

View file

@ -31,7 +31,7 @@ class EncodeText extends Operation {
].join("\n");
this.infoURL = "https://wikipedia.org/wiki/Character_encoding";
this.inputType = "string";
this.outputType = "byteArray";
this.outputType = "ArrayBuffer";
this.args = [
{
"name": "Encoding",
@ -44,13 +44,12 @@ class EncodeText extends Operation {
/**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
* @returns {ArrayBuffer}
*/
run(input, args) {
const format = IO_FORMAT[args[0]];
let encoded = cptable.utils.encode(format, input);
encoded = Array.from(encoded);
return encoded;
const encoded = cptable.utils.encode(format, input);
return new Uint8Array(encoded).buffer;
}
}