The main usage of the CastoeFile.
const castoeStreamer = require('castoe-streamer');
// Console transport.
const castoeFile = new castoeStreamer.CastoeFile({});
// Information to send to a file.
castoeFile.send('Some info to send');
Castoe file currently contains 4 methods that can be used.
Writes to a file specified in the CastoeFileOptions.
Parameter Type input String
Example:
const castoestreamer = require('castoe-streamer'); const castoeFile = new castoestreamer.CastoeFile({ file: 'castoeFile.txt' }); castoeFile.send('Data to send to file.');Returns {Promise}
Reads data from the file specified in the CastoeFileOptions.
Parameter Type callback Function
Example:
const castoestreamer = require('castoe-streamer'); const castoeFile = new castoestreamer.CastoeFile({ file: 'castoeFile.txt' }); castoeFile.read((data) => console.debug(data));Returns {undefined}
Clones the file specified in the CastoeFileOptions.
Parameter Type cloneFile String
Example:
const castoestreamer = require('castoe-streamer'); const castoeFile = new castoestreamer.CastoeFile({ file: 'castoeFile.txt' }); castoeFile.clone('newClone.txt');Returns {Promise}
Deletes the file specified in the CastoeFileOptions.
Example:
const castoestreamer = require('castoe-streamer'); const castoeFile = new castoestreamer.CastoeFile({ file: 'castoeFile.txt' }); castoeFile.delete();Returns {Promise}
Creates a Gzipped file.
Example:
const castoestreamer = require('castoe-streamer'); const castoeFile = new castoestreamer.CastoeFile({ file: 'castoeFile.txt' }); castoeFile.createGzip();Returns {Promise}
Options for the CastoeFile in Object format.
Key Value Description file String The name of the file that gets written. dirname? Boolean This option specifies in which directory the automated backups should be saved. automatic? Boolean Wether automated backups should be enabled or not. overwrite? Boolean Should the backup file be overwritten or should there be a new file created? options? CastoeFileStreamOptions Option for how the file should be written. fs.createWriteStream() options.
Options for the fs.createWriteStream method. Below are the values that are used within the package. You can always adjust more by adding using the options found here.
Key Value Description flags String File system flags. encoding String Text encoding. Default is: 'utf-8'.