Quellcode durchsuchen

Adjustment to consumeWhile

n1073645 vor 5 Jahren
Ursprung
Commit
e9b7a43b9a
1 geänderte Dateien mit 7 neuen und 2 gelöschten Zeilen
  1. 7 2
      src/core/lib/Stream.mjs

+ 7 - 2
src/core/lib/Stream.mjs

@@ -190,7 +190,7 @@ export default class Stream {
             found = true;
             found = true;
 
 
             // Loop through the elements comparing them to val.
             // 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]) {
                 if (this.bytes[this.position-length + x] !== val[x]) {
                     found = false;
                     found = false;
 
 
@@ -213,7 +213,12 @@ export default class Stream {
      * @param {Number} val
      * @param {Number} val
      */
      */
     consumeWhile(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++;
+        }
     }
     }
 
 
     /**
     /**