mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2024-11-22 14:12:07 +00:00
28 lines
428 B
JavaScript
28 lines
428 B
JavaScript
'use strict';
|
|
|
|
const fs = require('fs');
|
|
|
|
module.exports = (pathToFile) => {
|
|
const path = pathToFile;
|
|
|
|
return {
|
|
read() {
|
|
if (!fs.existsSync(path))
|
|
return null;
|
|
return fs.readFileSync(path, { encoding: 'utf8' });
|
|
},
|
|
|
|
write(data) {
|
|
fs.writeFileSync(path, data, { encoding: 'utf8' });
|
|
return this;
|
|
},
|
|
|
|
hasData() {
|
|
if (fs.existsSync(path))
|
|
return this.read() !== '';
|
|
|
|
return false;
|
|
},
|
|
};
|
|
};
|