Adjustment to consumeWhile

This commit is contained in:
n1073645 2019-11-13 17:11:04 +00:00
parent 3921b4f445
commit e9b7a43b9a
1 changed files with 7 additions and 2 deletions

View File

@ -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++;
}
}
/**