From 5dc63c4e2237e2c85d5681960a32755887c0fcff Mon Sep 17 00:00:00 2001 From: eagleloid Date: Sat, 16 Jan 2021 14:54:29 -0600 Subject: [PATCH 1/2] :bug: validate frame count to fail gracefully If 'render' is ran with no frames, @running will remain 'True' until the class is reconstructed. --- src/gif.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gif.coffee b/src/gif.coffee index 0cf8f69..e7e81c2 100644 --- a/src/gif.coffee +++ b/src/gif.coffee @@ -69,6 +69,8 @@ class GIF extends EventEmitter @frames.push frame render: -> + throw new Error 'Frames must be added prior to rendering' if @frames.length == 0 + throw new Error 'Already running' if @running if not @options.width? or not @options.height? From 8abcf7875fb2a115564401ab09c4cb2da9ce9908 Mon Sep 17 00:00:00 2001 From: eagleloid Date: Sat, 16 Jan 2021 15:11:39 -0600 Subject: [PATCH 2/2] :bug: set 'running' to false when rendering is finished Set running variable to FALSE at the end of the 'finishRendering' method so user can render again without having to reconstruct class. --- src/gif.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gif.coffee b/src/gif.coffee index e7e81c2..d37726d 100644 --- a/src/gif.coffee +++ b/src/gif.coffee @@ -149,6 +149,7 @@ class GIF extends EventEmitter type: 'image/gif' @emit 'finished', image, data + @running = false renderNextFrame: -> throw new Error 'No free workers' if @freeWorkers.length is 0