file-system-service
v0.1.0
Published
An OO file system service that uses the Node fs module.
Downloads
4
Readme
file-system-service
An OO file system service that uses the Node fs module.
Usage
npm install file-system-service
Async File Read
const FileSystemService = require('file-system-service');
const fileSystemService = new FileSystemService();
fileSystemService.readFile('myFile.txt')
.then(fileContents => {
console.log(fileContents);
})
.catch(err => {
console.error(err);
});
Sync File Read
const FileSystemService = require('file-system-service');
const fileSystemService = new FileSystemService();
try {
const fileContents = fileSystemService
.readFileSync('myFile.txt');
console.log(fileContents);
} catch (err) {
console.error(err);
}
Async JSON File Read
const FileSystemService = require('file-system-service');
const fileSystemService = new FileSystemService();
fileSystemService.readFile('myJsonFile.json')
.then(json => {
console.log(JSON.stringify(json));
})
.catch(err => {
console.error(err);
});
Sync JSON File Read
const FileSystemService = require('file-system-service');
const fileSystemService = new FileSystemService();
try {
const json = fileSystemService
.readFileSync('myJsonFile.json');
console.log(JSON.stringify(json));
} catch (err) {
console.error(err);
}
Testing
npm test