mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2024-11-25 15:42:07 +00:00
30 lines
520 B
JavaScript
30 lines
520 B
JavaScript
'use strict';
|
|
|
|
const fs = require('fs');
|
|
|
|
module.exports = (pathToFile) => {
|
|
const path = pathToFile;
|
|
|
|
return {
|
|
write(data) {
|
|
return new Promise((resolve, reject) => {
|
|
fs.writeFile(path, data, { encoding: 'utf8' }, (error) => {
|
|
if (error) reject(error);
|
|
|
|
return resolve();
|
|
});
|
|
});
|
|
},
|
|
|
|
read() {
|
|
return new Promise((resolve, reject) => {
|
|
fs.readFile(path, { encoding: 'utf8' }, (error, data) => {
|
|
if (error) reject(error);
|
|
|
|
return resolve(data);
|
|
});
|
|
});
|
|
},
|
|
};
|
|
};
|