CodeParser Class
The CodeParser
class enable users to parse given bytes or a string to be human-readable.
Method | Description |
---|---|
static createInstance() |
Initializes a new instance of the CodeParser class. |
dispose() | Releases all resources used by the CodeParser object. |
disposed | Returns whether the CodeParser object has been disposed of. |
initSettings | Initializes runtime settings with the settings in a given JSON string. |
resetSettings | Resets runtime settings to default. |
parse | Parses code data for readable results. |
createInstance
Initializes a new instance of the CodeParser
class.
Syntax
createInstance(): Promise<CodeParser>;
Parameter
None.
Return value
A promise that resolves to the initialized CodeParser
object.
Code snippet
let parser = await Dynamsoft.DCP.CodeParser.createInstance();
dispose
Releases all resources used by the CodeParser
object.
Syntax
dispose(): Promise<void>;
Parameter
None.
Return value
Returns a promise that resolves when the resources have been successfully released.
Code snippet
let parser = await Dynamsoft.DCP.CodeParser.createInstance();
// Use the parser to perform a job.
// ...
// Release the resources after the job is finished.
parser.dispose();
disposed
Returns whether the CodeParser
object has been disposed of.
Syntax
disposed: boolean;
Parameter
None.
Return value
A boolean value that indicates whether the CodeParser
object has been disposed of.
Code snippet
if(parser.disposed){
console.log("The parser has been disposed of.");
} else {
// Use the parser to perform a job.
}
initSettings
Initializes settings from a given string.
initSettings: (settings: string) => Promise<void>;
Parameters
settings
: A JSON string that represents the content of the settings.
Return value
A promise that resolves when the operation has completed. It does not provide any value upon resolution.
resetSettings
Resets all parameters to default values.
resetSettings: () => Promise<void>;
Parameters
None.
Return value
Returns a promise that resolves when the settings have been successfully reset to their default values.
parse
Parses a single string to be human-readable.
parse: (source: Uint8Array | string | Array<number>, taskSettingName?: string) => Promise<ParsedResultItem>;
Parameters
-
source
: the array of bytes or the string to parse. -
taskSettingName
: the name of CodeParserTaskSetting that defines the settings used for code parsing.
Return Value
Returns an array of ParsedResultItem containing the human-readable results.