node-ebics-client/lib/storages/fsKeysStorage.js

30 lines
520 B
JavaScript
Raw Permalink Normal View History

2018-06-15 06:33:41 +00:00
'use strict';
const fs = require('fs');
module.exports = (pathToFile) => {
const path = pathToFile;
return {
2018-06-27 14:59:35 +00:00
write(data) {
return new Promise((resolve, reject) => {
fs.writeFile(path, data, { encoding: 'utf8' }, (error) => {
2018-06-28 08:34:14 +00:00
if (error) reject(error);
2018-06-27 14:59:35 +00:00
return resolve();
});
});
2018-06-15 06:33:41 +00:00
},
2018-06-27 14:59:35 +00:00
read() {
return new Promise((resolve, reject) => {
fs.readFile(path, { encoding: 'utf8' }, (error, data) => {
if (error) reject(error);
return resolve(data);
});
});
2018-06-15 06:33:41 +00:00
},
};
};