From 1cee7a3975573257921c9b50899d2e252374e7c0 Mon Sep 17 00:00:00 2001 From: Trevor Manz Date: Wed, 9 Sep 2020 11:52:09 -0400 Subject: [PATCH 1/2] async-ify decoders and await decodeBlock --- src/compression/basedecoder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compression/basedecoder.js b/src/compression/basedecoder.js index 1d5b8b42..5426920d 100644 --- a/src/compression/basedecoder.js +++ b/src/compression/basedecoder.js @@ -1,8 +1,8 @@ import { applyPredictor } from '../predictor'; export default class BaseDecoder { - decode(fileDirectory, buffer) { - const decoded = this.decodeBlock(buffer); + async decode(fileDirectory, buffer) { + const decoded = await this.decodeBlock(buffer); const predictor = fileDirectory.Predictor || 1; if (predictor !== 1) { const isTiled = !fileDirectory.StripOffsets; From bdc9cc92f61cb27be8f4fe7e312c8ed87ad80e3a Mon Sep 17 00:00:00 2001 From: Trevor Manz Date: Thu, 10 Sep 2020 10:20:28 -0400 Subject: [PATCH 2/2] await Decoder.decode in worker --- src/decoder.worker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/decoder.worker.js b/src/decoder.worker.js index 5529d720..9c09beaf 100644 --- a/src/decoder.worker.js +++ b/src/decoder.worker.js @@ -1,9 +1,10 @@ import { expose, Transfer } from 'threads/worker'; import { getDecoder } from './compression'; -function decode(fileDirectory, buffer) { +async function decode(fileDirectory, buffer) { const decoder = getDecoder(fileDirectory); - return Transfer(decoder.decode(fileDirectory, buffer)); + const decoded = await decoder.decode(fileDirectory, buffer); + return Transfer(decoded); } expose(decode);