Skip to content

Commit

Permalink
Merge pull request #52 from rodbv/issue-49
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Sep 24, 2020
2 parents 8945ea7 + ffaeb5b commit 9f9f5fb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/yarle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const parseStream = async (options: YarleOptions): Promise<void> => {
const xml = new XmlStream(stream);
let noteNumber = 0;
let failed = 0;
let totalNotes = 0;

const xmlStream = flow(stream);

return new Promise((resolve, reject) => {
Expand All @@ -34,7 +36,9 @@ export const parseStream = async (options: YarleOptions): Promise<void> => {

return reject();
};

xmlStream.on('tag:en-export', (enExport: any) => {
totalNotes = Array.isArray(enExport.note) ? enExport.note.length : 1;
});
xmlStream.on('tag:note', (note: any) => {
processNode(note);
++noteNumber;
Expand All @@ -43,7 +47,9 @@ export const parseStream = async (options: YarleOptions): Promise<void> => {
xmlStream.on('end', () => {
const success = noteNumber - failed;
console.log(
`Conversion finished: ${success} succeeded, ${failed} failed`,
`Conversion finished: ${success} succeeded, ${
totalNotes - success
} failed.`
);

return resolve();
Expand Down

0 comments on commit 9f9f5fb

Please sign in to comment.