skiz-parser 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +9 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import csv from 'csv-parser';
|
|
2
2
|
import { XMLParser } from 'fast-xml-parser';
|
|
3
|
-
import { promisify } from 'util';
|
|
4
3
|
import yauzl from 'yauzl';
|
|
5
4
|
|
|
6
5
|
const parser = new XMLParser({
|
|
@@ -23,6 +22,14 @@ const convertReadStreamToBuffer = (readStream) => {
|
|
|
23
22
|
});
|
|
24
23
|
};
|
|
25
24
|
|
|
25
|
+
const openReadStream = (zipFile, entry) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
zipFile.openReadStream(entry, (err, readStream) => {
|
|
28
|
+
err ? reject(err) : resolve(readStream);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
26
33
|
const parseBatteryCsvFile = (readStream) => {
|
|
27
34
|
return new Promise((resolve, reject) => {
|
|
28
35
|
const batteryUsage = [];
|
|
@@ -219,8 +226,6 @@ export const parseSkizFile = (contents, callback) => {
|
|
|
219
226
|
|
|
220
227
|
let data = {};
|
|
221
228
|
|
|
222
|
-
const openReadStream = promisify(zipFile.openReadStream.bind(zipFile));
|
|
223
|
-
|
|
224
229
|
zipFile.readEntry();
|
|
225
230
|
|
|
226
231
|
zipFile
|
|
@@ -239,7 +244,7 @@ export const parseSkizFile = (contents, callback) => {
|
|
|
239
244
|
return zipFile.readEntry();
|
|
240
245
|
}
|
|
241
246
|
|
|
242
|
-
const readStream = await openReadStream(entry);
|
|
247
|
+
const readStream = await openReadStream(zipFile, entry);
|
|
243
248
|
|
|
244
249
|
let result;
|
|
245
250
|
if (entry.fileName === 'Battery.csv') {
|