client and order optimization

This commit is contained in:
Vladislav Hristov
2018-06-20 12:20:03 +03:00
parent 187636019c
commit 945499290a
15 changed files with 259 additions and 194 deletions

View File

@@ -0,0 +1,27 @@
'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;
},
};
};