Remove Buffer from Dish. Convert into ByteArray in api and then pass in as ArrayBuffer. Add some PNG files to tests

This commit is contained in:
d98762625 2018-08-19 22:55:40 +01:00
parent 20bb104006
commit 55f7cac526
3 changed files with 14 additions and 45 deletions

View file

@ -108,15 +108,20 @@ function ensureIsDish(input) {
dish.set(input, type);
}
return dish;
};
}
/**
* prepareOp: transform args, make input the right type.
* Also convert any Buffers to ArrayBuffers.
* @param opInstance - instance of the operation
* @param input - operation input
* @param args - operation args
*/
function prepareOp(opInstance, input, args) {
// convert any Buffers into ArrayBuffers.
if (input instanceof Buffer) {
input = input.buffer;
}
const dish = ensureIsDish(input);
let transformedArgs;
// Transform object-style args to original args array
@ -127,7 +132,7 @@ function prepareOp(opInstance, input, args) {
}
const transformedInput = dish.get(opInstance.inputType);
return {transformedInput, transformedArgs};
};
}
/**
* Wrap an operation to be consumed by node API.