Nodebook is a module that you can use to edit, manage, and configure external files, like a notebook.
Installation
npm install nodenotes
Usage
Nodebook
Nodebook has a default class in case you want to edit files that do not have their own custom formatting.
Setup
const Nodebook = require('node-notebook');
const myNotebook = new Nodebook.Nodebook('file name', 'txt');
fileName(options)
object options
:
options.lower
- Whether or not the name should be turned to lower case.
Return: The file name.
myNotebook.fileName({ lower: false });
clearLog()
Clears .booklog.txt
myNotebook.clearLog();
resetFile()
Resets the file.
myNotebook.resetFile();
deleteFile(delay)
Deletes the file
number delay
:
Sets how many seconds before deleting the file.
myNotebook.deleteFile();
myNotebook.deleteFile(3);
fetchLine(line)
Fetches an existing line's content.
number line
:
The line number to get the information from.
myNootebook.fetchLine(1);
myNotebook.fetchLine(5);
Return: The line content.
deleteLine(line)
Sets an existing line in the file to empty.
number line
:
The line number to make empty.
myNotebook.deleteLine(1);
editLine(line, key)
Replaces an existing lin ewith a new string.
number line
:
The line number to set it to.
string key
:
The string that will replace the line.
myNotebook.editLine(1, 'Welcome!');
addLine(key)
Adds a string at the next available line in the file.
string key
:
The string to add at the next available line.
myNotebook.addLine('Yippi Ki Yay!');
content()
Returns the file's content into a string.
console.log(myNotebook.content());
Documentation
There are more customized classes for different types of files on the Documentation.