Skip to content

Commit

Permalink
Review: use Async Function in async.eachSeries instead of acomb.ensur…
Browse files Browse the repository at this point in the history
…eAsync
  • Loading branch information
lvancraen committed Jun 21, 2019
1 parent 809cd98 commit e233490
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 7 additions & 11 deletions helpers/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/* eslint-disable no-underscore-dangle */

const acomb = require('acomb');
const async = require('async');
const infoLog = require('debug')('gtfsNodeLib:i');
const warningLog = require('debug')('gtfsNodeLib:w');
Expand Down Expand Up @@ -104,7 +103,7 @@ function exportTable(tableName, gtfs, outputPath, callback) {

let rows = [];

async.eachSeries(gtfs.getIndexedTable(tableName), acomb.ensureAsync(([key, object], subDone) => {
async.eachSeries(gtfs.getIndexedTable(tableName), async ([key, object]) => {
if (deepness === 0 || deepness === 1) {
if (gtfs._preExportItemFunction) {
object = gtfs._preExportItemFunction(object, tableName, key);
Expand Down Expand Up @@ -140,19 +139,16 @@ function exportTable(tableName, gtfs, outputPath, callback) {
}

if (rows.length < 100) {
subDone();
return;
}

fs.appendFile(outputFullPath, rows.join(''), (appendingError) => {
if (appendingError) {
throw appendingError;
}
await fs.appendFile(outputFullPath, rows.join(''));
rows = [];
}, (asyncEachSeriesError) => {
if (asyncEachSeriesError) {
throw asyncEachSeriesError;
}

rows = [];
subDone();
});
}), () => {
if (rows.length === 0) {
infoLog(`[${getHHmmss()}] Table has been exported: ${tableName}`);
callback();
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
},
"homepage": "https://github.com/TransitApp/gtfsNodeLib#readme",
"dependencies": {
"acomb": "1.2.2",
"async": "2.6.0",
"debug": "3.1.0",
"fs-extra": "5.0.0",
Expand Down

0 comments on commit e233490

Please sign in to comment.