file-awesome v1.0.3
file-awesome
The file-awesome is a node module built in pure javascript, offers easy file manipulation with predefined functions, and even gives the flexibility to create your own as it simplifies basic CRUD operations of fs library with syntactical sugar.
Getting Started
Install file-awesome using npm
npm install file-awesome
Import file-awesome
const fileAwesome = require('file-awesome");
file-awesome methods
All the methods need pathname of the file as parameter in string note: you need to come to root directory of your node.js project from file-awesome module by using ../../ followed by continuation of the file path.
eg. for a file named as text.txt in the root directory of you project path will be ../../text.txt
Simplified fs library methods
Read File - fileAwesome.getFileData(
stringpathname);var response = fileAwesome.getFileData("../../text.txt");getFileData reads the file data and returns it in
stringfromat which can be manipulated asccordingly bu the user.
Write File - fileAwesome.getFileData(
stringpathname,stringdata);fileAwesome.writeFileData("../../text.txt","Data that need to be written in the file");writeFileData takes pathname in first parameter and data that need to be written in the second.
Append File - fileAwesome.appendDataAtlast(
stringpathname,stringdata);fileAwesome.appendDataAtlast("../../text.txt","this data appends at the last in the file");appendDataAtlast appends the data at the last of the file.
Delete File Data - fileAwesome.removeFileData(
stringpathname);fileAwesome.removeFileData("../../text.txt");removeFileData deletes the whole data in the file.
Delete File - fileAwesome.deleteFile(
stringpathname);fileAwesome.deleteFile("../../text.txt");deleteFile deletes the file in the specified directory.
File manipulation methods
Number of Charaters in a file - fileAwesome.numberOfAllChar(
stringpathname);var response = fileAwesome.numberOfAllChar("../../text.txt");numberOfAllChar returns the number of
charin a file, return typeint.
Number of Charaters in a file without space - fileAwesome.numberOfAllChar(
stringpathname);var response = fileAwesome.charWithoutSpace("../../text.txt");charWithoutSpace returns the number of
charin a file excluding spaces, return typeint.
First Charater - fileAwesome.firstChar(
stringpathname);var response = fileAwesome.firstChar("../../text.txt");firstChar returns the first
charin the specified file.
Last Charater - fileAwesome.lastChar(
stringpathname);var response = fileAwesome.lastChar("../../text.txt");lastChar returns the last
charin the specified file.
First Word - fileAwesome.firstWord(
stringpathname);var response = fileAwesome.firstWord("../../text.txt");firstWord returns the first word in the specified file as
string.
Last Word - fileAwesome.lastWord(
stringpathname);var response = fileAwesome.lastWord("../../text.txt");lastWord returns the first word in the specified file as
string.
Count words - fileAwesome.wordsCount(
stringpathname);var response = fileAwesome.wordsCount("../../text.txt");wordsCount returns the the number of words persent in the specified file as
int.
Lines words - fileAwesome.linesCount(
stringpathname);var response = fileAwesome.linesCount("../../text.txt");linesCount returns the the number of lines persent in the specified file as
int.
Charater on the placeValue - fileAwesome.placeCharater(
stringpathname,intplaceValue);var response = fileAwesome.placeCharater("../../text.txt",3);placeCharater returns the the
charpresent on the specifiedintplace in the file.
Word Present - fileAwesome.isPresent(
stringpathname,stringvalue);var response = fileAwesome.isPresent("../../text.txt","Hello");isPresent returns the the
booleanvalue to indicate weather the string is present in the file or not.
Replace first word occurance - fileAwesome.replaceWord(
stringpathname,stringvalueTobeReplaced,stringreplacingValue);var response = fileAwesome.replaceWord("../../text.txt","Hello","world");replaceWord replaces the first word occurance in the file which is specified in the second parameter and replaces it with the third parameter word of the function.