mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Add a new BaseStream.getString(...)
method to replace manual bytesToString(BaseStream.getBytes(...))
calls
Given that the `bytesToString(BaseStream.getBytes(...))` pattern is somewhat common throughout the `src/core/` code, it cannot hurt to add a new `BaseStream`-method which handles that case internally.
This commit is contained in:
parent
f6f335173d
commit
3624f9eac7
6 changed files with 33 additions and 32 deletions
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { shadow, unreachable } from "../shared/util.js";
|
||||
import { bytesToString, shadow, unreachable } from "../shared/util.js";
|
||||
|
||||
class BaseStream {
|
||||
constructor() {
|
||||
|
@ -79,6 +79,10 @@ class BaseStream {
|
|||
unreachable("Abstract method `getByteRange` called");
|
||||
}
|
||||
|
||||
getString(length) {
|
||||
return bytesToString(this.getBytes(length, /* forceClamped = */ false));
|
||||
}
|
||||
|
||||
skip(n) {
|
||||
this.pos += n || 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue