Tidied up consumeWhile and consumeUntil
This commit is contained in:
1 parent
ea6d80edfb
commit
03f4740968
1 file changed
+2
-5
@@ -156,7 +156,6 @@ export default class Stream {
|
|||||||
|
|
||||||
// val is an array
|
// val is an array
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the skip forward table from the value to be searched.
|
* Builds the skip forward table from the value to be searched.
|
||||||
*
|
*
|
||||||
@@ -173,9 +172,7 @@ export default class Stream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const length = val.length;
|
const length = val.length;
|
||||||
|
|
||||||
const initial = val[length-1];
|
const initial = val[length-1];
|
||||||
|
|
||||||
this.position = length;
|
this.position = length;
|
||||||
|
|
||||||
// Get the skip table.
|
// Get the skip table.
|
||||||
@@ -183,7 +180,6 @@ export default class Stream {
|
|||||||
let found = true;
|
let found = true;
|
||||||
|
|
||||||
while (this.position < this.length) {
|
while (this.position < this.length) {
|
||||||
|
|
||||||
// Until we hit the final element of val in the stream.
|
// Until we hit the final element of val in the stream.
|
||||||
while ((this.position < this.length) && (this.bytes[this.position++] !== initial));
|
while ((this.position < this.length) && (this.bytes[this.position++] !== initial));
|
||||||
|
|
||||||
@@ -208,7 +204,7 @@ export default class Stream {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consume bytes if it matches the supplied value.
|
* Consume bytes if they match the supplied value.
|
||||||
*
|
*
|
||||||
* @param {Number} val
|
* @param {Number} val
|
||||||
*/
|
*/
|
||||||
@@ -219,6 +215,7 @@ export default class Stream {
|
|||||||
}
|
}
|
||||||
this.position++;
|
this.position++;
|
||||||
}
|
}
|
||||||
|
this.bitPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user