Introduced more defensive checking for the end of a recipe.

This commit is contained in:
n1474335 2017-03-06 13:17:58 +00:00
parent 7f0ce0da8d
commit 824c3935d9

View file

@ -159,8 +159,7 @@ Recipe.prototype.execute = function(dish, currentStep, state) {
return e; return e;
}; };
// Operations can be asynchronous so we have to return a Promise to a // Operations can be asynchronous so we have to return a Promise to a future value.
// future value.
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
// Helper function to clean up recursing to the next recipe step. // Helper function to clean up recursing to the next recipe step.
// It is a closure to avoid having to pass in resolve and reject. // It is a closure to avoid having to pass in resolve and reject.
@ -180,7 +179,7 @@ Recipe.prototype.execute = function(dish, currentStep, state) {
currentStep = currentStep || 0; currentStep = currentStep || 0;
if (currentStep === recipe.opList.length) { if (currentStep >= recipe.opList.length) {
resolve(currentStep); resolve(currentStep);
return; return;
} }