mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2024-11-21 21:52:07 +00:00
feat: async letter serialization
This commit is contained in:
parent
67d74cfa00
commit
a10a3a8d63
@ -24,6 +24,12 @@ const registerHelpers = () => {
|
||||
return digest.toUpperCase().match(/.{1,2}/g).join(' ');
|
||||
});
|
||||
};
|
||||
|
||||
const writeFile = (file, content) => new Promise((resolve, reject) => fs.writeFile(file, content, (err, result) => {
|
||||
if (err)
|
||||
return reject(err);
|
||||
return resolve(result);
|
||||
}));
|
||||
module.exports = class BankLetter {
|
||||
constructor({
|
||||
client,
|
||||
@ -55,13 +61,7 @@ module.exports = class BankLetter {
|
||||
|
||||
async serialize(path) {
|
||||
const letter = await this.generate();
|
||||
|
||||
try {
|
||||
fs.writeFileSync(path, letter);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return new Promise(resolve => resolve(true));
|
||||
await writeFile(path, letter);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user