From e9b7a43b9a8fd0fd50c7ee423184d63357c33461 Mon Sep 17 00:00:00 2001 From: n1073645 Date: Wed, 13 Nov 2019 17:11:04 +0000 Subject: [PATCH] Adjustment to consumeWhile --- src/core/lib/Stream.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/lib/Stream.mjs b/src/core/lib/Stream.mjs index 8e941716..451698b9 100644 --- a/src/core/lib/Stream.mjs +++ b/src/core/lib/Stream.mjs @@ -190,7 +190,7 @@ export default class Stream { found = true; // Loop through the elements comparing them to val. - for (let x = length-1; x > -1; x--) { + for (let x = length-1; x >= 0; x--) { if (this.bytes[this.position-length + x] !== val[x]) { found = false; @@ -213,7 +213,12 @@ export default class Stream { * @param {Number} val */ consumeWhile(val) { - while ((++this.position < this.length) && (this.bytes[(this.position)] === val)); + while (this.position < this.length){ + if (this.bytes[this.position] !== val){ + break; + } + this.position++; + } } /**