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