-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparser.js
40 lines (38 loc) · 1.14 KB
/
parser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Base class for all parsers.
* Parser is object that performs specific parsing
* and updates its result with data extracted from the image.
*/
export class Parser {
constructor(parserType) {
/** Type of parser */
this.parserType = parserType;
/** Defines/returns whether the parser configured with this parser settings object will be required or optional. */
this.required = true;
}
}
/**
* Possible states of the Parser's result
*/
export const ParserResultState = Object.freeze(
{
/** Parser result is empty */
empty : 1,
/** Parser result contains some values, but is incomplete or it contains all values, but some are uncertain */
uncertain : 2,
/** Parser result contains all required values */
valid : 3
}
);
/**
* Base class for all parsers's result objects.
* Parser result contains data extracted from the image.
*/
export class ParserResult {
constructor(resultState) {
/**
* State of the result. It is always one of the values represented by ParserResultState enum
*/
this.resultState = resultState;
}
}