FileParser
Summary
The FileParer class is an abstract class that need to be extended. If this class is used directly, it will return the contents of a file without parsing them.
Item Index
Methods
decode
Syntax
decode
-
[data]
Summary
Decodes the data, turning a String that is read from a file to an Object usable by JavaScript.
Parameters:
-
[data]
String optional
Returns:
encode
Syntax
encode
-
[data]
Summary
Encodes the data, turning an Object into a String that can be written to a file.
Parameters:
-
[data]
Object | String optional
Returns:
FileParser
Syntax
FileParser
-
file
Summary
Creates a new FileParser.
Parameters:
-
file
StringThe location of the file.
getContent
Syntax
getContent
()
String | Object
Summary
Gets the (cached) parsed content of the file, when it was last read.
Returns:
The content of the file, after being parsed by the subclass.
getFile
Syntax
getFile
()
String
Summary
Gets the file, but not the content.
Returns:
The file location that was supplied to the constructor.
getRawContent
Syntax
getRawContent
()
String
Summary
Gets the (cached) raw content of the file, when it was last read.
Returns:
The content of the file, without being parsed.
modify
Syntax
modify
-
[watcher]
Summary
Adds a callback function to the parser, so that each entry can be modified to tailor specific needs. Only one callback can be active at any given time.
Parameters:
-
[watcher]
Function optionalThe callback that should be called by the parser, or
undefined
if the callback should be cleared.
read
Syntax
read
-
callback
Summary
Reads the file into the current raw content and then parses it.
Parameters:
-
callback
Object
setContent
Syntax
setContent
-
[content]
Summary
Sets the content of this file, but does not yet write to the file.
Parameters:
-
[content]
Object optional
write
Syntax
write
()
chainable
Summary
Writes or updates the file with the current parsed content.