mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Change the signature of the Parser
constructor to take a parameter object
A lot of the `new Parser()` call-sites look quite unwieldy/ugly as-is, with a bunch of somewhat randomly ordered arguments, which we can avoid by changing the constructor to accept an object instead. As an added bonus, this provides better documentation without having to add inline argument comments in the code.
This commit is contained in:
parent
1c9a69db82
commit
f710eb56e4
5 changed files with 53 additions and 21 deletions
|
@ -51,10 +51,10 @@ function computeAdler32(bytes) {
|
|||
}
|
||||
|
||||
class Parser {
|
||||
constructor(lexer, allowStreams, xref, recoveryMode = false) {
|
||||
constructor({ lexer, xref, allowStreams = false, recoveryMode = false, }) {
|
||||
this.lexer = lexer;
|
||||
this.allowStreams = allowStreams;
|
||||
this.xref = xref;
|
||||
this.allowStreams = allowStreams;
|
||||
this.recoveryMode = recoveryMode;
|
||||
|
||||
this.imageCache = Object.create(null);
|
||||
|
@ -748,7 +748,7 @@ function toHexDigit(ch) {
|
|||
}
|
||||
|
||||
class Lexer {
|
||||
constructor(stream, knownCommands) {
|
||||
constructor(stream, knownCommands = null) {
|
||||
this.stream = stream;
|
||||
this.nextChar();
|
||||
|
||||
|
@ -1202,7 +1202,10 @@ class Linearization {
|
|||
throw new Error('Hint array in the linearization dictionary is invalid.');
|
||||
}
|
||||
|
||||
const parser = new Parser(new Lexer(stream), false, null);
|
||||
const parser = new Parser({
|
||||
lexer: new Lexer(stream),
|
||||
xref: null,
|
||||
});
|
||||
const obj1 = parser.getObj();
|
||||
const obj2 = parser.getObj();
|
||||
const obj3 = parser.getObj();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue