1
0
mirror of synced 2024-11-15 10:47:41 +01:00

ESM: Fixed magic errors

This commit is contained in:
n1474335 2018-06-01 12:43:36 +00:00
parent 37c8d1b7ea
commit a0f034b843

View File

@ -229,17 +229,22 @@ class Magic {
const testEnc = async op => { const testEnc = async op => {
for (let i = 0; i < encodings.length; i++) { for (let i = 0; i < encodings.length; i++) {
const conf = { const conf = {
op: op, op: op,
args: [encodings[i]] args: [encodings[i]]
}, };
data = await this._runRecipe([conf], sample.buffer);
// Only add to the results if it changed the data try {
if (!_buffersEqual(data, sample.buffer)) { const data = await this._runRecipe([conf], sample.buffer);
results.push({
data: data, // Only add to the results if it changed the data
conf: conf if (!_buffersEqual(data, sample.buffer)) {
}); results.push({
data: data,
conf: conf
});
}
} catch (err) {
continue;
} }
} }
}; };
@ -356,8 +361,9 @@ class Magic {
* @returns {ArrayBuffer} * @returns {ArrayBuffer}
*/ */
async _runRecipe(recipeConfig, input=this.inputBuffer) { async _runRecipe(recipeConfig, input=this.inputBuffer) {
input = input instanceof ArrayBuffer ? input : input.buffer;
const dish = new Dish(); const dish = new Dish();
dish.set(input.buffer, Dish.ARRAY_BUFFER); dish.set(input, Dish.ARRAY_BUFFER);
if (ENVIRONMENT_IS_WORKER()) self.loadRequiredModules(recipeConfig); if (ENVIRONMENT_IS_WORKER()) self.loadRequiredModules(recipeConfig);