mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2024-11-22 06:02:09 +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(' ');
|
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));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user