node-ebics-client/packages/ebics-client/lib/storages/fsKeysStorage.js
2019-10-11 10:46:37 +03:00

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);
});
});
},
};
};