node-ebics-client/lib/storages/fsKeysStorage.js
2018-06-27 17:59:35 +03:00

30 lines
518 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) throw error;
return resolve();
});
});
},
read() {
return new Promise((resolve, reject) => {
fs.readFile(path, { encoding: 'utf8' }, (error, data) => {
if (error) reject(error);
return resolve(data);
});
});
},
};
};