From b3cb800f3573e63bb2e2093ac9cc9e131247a938 Mon Sep 17 00:00:00 2001 From: j433866 Date: Mon, 3 Jun 2019 14:01:00 +0100 Subject: [PATCH] Default inputNum to -1 when one isn't sent. Improve jsdoc comments --- src/core/ChefWorker.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/ChefWorker.js b/src/core/ChefWorker.js index 2292efb6..297a4084 100644 --- a/src/core/ChefWorker.js +++ b/src/core/ChefWorker.js @@ -37,9 +37,8 @@ self.postMessage({ /** * Respond to message from parent thread. * - * An inputNum only needs to be sent when baking. - * (The background ChefWorker doesn't send one, but as - * it only deals with one input at a time it isn't needed) + * inputNum is optional and only used for baking multiple inputs. + * Defaults to -1 when one isn't sent with the bake message. * * Messages should have the following format: * { @@ -99,7 +98,7 @@ async function bake(data) { // Ensure the relevant modules are loaded self.loadRequiredModules(data.recipeConfig); try { - self.inputNum = data.inputNum; + self.inputNum = (data.inputNum !== undefined) ? data.inputNum : -1; const response = await self.chef.bake( data.input, // The user's input data.recipeConfig, // The configuration of the recipe