feat: async letter serialization

This commit is contained in:
nanov 2019-11-20 14:40:18 +02:00
parent 67d74cfa00
commit a10a3a8d63

View File

@ -24,6 +24,12 @@ const registerHelpers = () => {
return digest.toUpperCase().match(/.{1,2}/g).join(' '); 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 { module.exports = class BankLetter {
constructor({ constructor({
client, client,
@ -55,13 +61,7 @@ module.exports = class BankLetter {
async serialize(path) { async serialize(path) {
const letter = await this.generate(); const letter = await this.generate();
await writeFile(path, letter);
try { return true;
fs.writeFileSync(path, letter);
} catch (error) {
throw error;
}
return new Promise(resolve => resolve(true));
} }
}; };