Constructor
new TagFileParser(bagItFile)
Parameters:
Name | Type | Description |
---|---|---|
bagItFile |
BagItFile |
A BagItFile object. If the object does not already have a keyValueCollection, the parser will create one. For more on the BagIt spec, see BagIt Spec For info about how to read the parsed data from the file, see KeyValueCollection |
- Source:
Example
// Set up a BagItFile
let pathToTagFile = "/path/to/bag-info.txt";
let stats = fs.statSync(pathToTagFile);
let bagItFile = new BagItFile(pathToTagFile, "bag-info.txt", stats);
// Open the BagItFile for reading
let stream = fs.createReadStream(pathToTagFile);
// Create a new TagFileParser to parse the BagItFile
let tagFileParser = new TagFileParser(bagItFile);
// Optional: Hook up your callback to do something with
// bagItFile when the parsing is done.
tagFileParser.stream.on('end', YOUR_CALLBACK_HERE);
// Required: Pipe your file reader into the parser.
stream.pipe(tagFileParser.stream).on('error', function(e){handleError(e)});
Members
bagItFile :BagItFile
bagItFile is the file that will be parsed. When parsing is complete, bagItFile.keyValueCollection will be populated with tag names and values.
- Source:
content :string
content is a string that accumulates the contents of the tag file. This is considered private but is ok to access as a read-only property.
- Source:
stream :stream.PassThrough
stream is a PassThrough stream that allows for data to be piped from a ReadStream into the parser. You can attach your own 'data' and 'end' events to this stream, but the parser already does the parsing work for you.
- Source: