Skip to content

Commit

Permalink
ensure async so sync onBoundary doesnt overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Jun 29, 2016
1 parent 1b442a4 commit f858072
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exports.default = function (overrides, _ref) {
onBoundary: onBoundary
};

_async2.default.forEachSeries(options.objects, processObject.bind(null, context), onFinish);
_async2.default.forEachSeries(options.objects, _async2.default.ensureAsync(processObject.bind(null, context)), onFinish);
});
};

Expand All @@ -78,7 +78,7 @@ function processObject(context, object, cb) {
fetchObjectFiles(context, object, function (err, filePaths) {
if (err) return cb(err);
debug(_chalk2.default.bold('Processing ' + filePaths.length + ' boundary ' + (0, _plural2.default)('file', filePaths.length) + ' for ' + object));
_async2.default.forEachSeries(filePaths, processFilePath.bind(null, context), cb);
_async2.default.forEachSeries(filePaths, _async2.default.ensureAsync(processFilePath.bind(null, context)), cb);
});
}

Expand All @@ -102,7 +102,7 @@ function processFilePath(context, file, cb) {
srcStream.once('end', function () {
var docs = JSON.parse(_buffer.Buffer.concat(chunks)).features;
debug(' -- ' + _chalk2.default.cyan('Parsed ' + file.path + ', inserting ' + docs.length + ' boundaries now...'));
_async2.default.forEachSeries(docs, context.onBoundary.bind(null, file.type), cb);
_async2.default.forEach(docs, _async2.default.ensureAsync(context.onBoundary.bind(null, file.type)), cb);
});

stream.resume();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "census-boundaries",
"version": "1.0.3",
"version": "1.0.4",
"description": "Downloads and converts US Census TIGER data representing all boundaries in the United States",
"main": "dist/index.js",
"keywords": [
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default (overrides, { onBoundary, onFinish }) => {
onBoundary
}

async.forEachSeries(options.objects, processObject.bind(null, context), onFinish)
async.forEachSeries(options.objects, async.ensureAsync(processObject.bind(null, context)), onFinish)
})
}

Expand All @@ -40,7 +40,7 @@ function processObject(context, object, cb) {
fetchObjectFiles(context, object, (err, filePaths) => {
if (err) return cb(err)
debug(chalk.bold(`Processing ${filePaths.length} boundary ${plural('file', filePaths.length)} for ${object}`))
async.forEachSeries(filePaths, processFilePath.bind(null, context), cb)
async.forEachSeries(filePaths, async.ensureAsync(processFilePath.bind(null, context)), cb)
})
}

Expand All @@ -61,7 +61,7 @@ function processFilePath(context, file, cb) {
srcStream.once('end', () => {
const docs = JSON.parse(Buffer.concat(chunks)).features
debug(` -- ${chalk.cyan(`Parsed ${file.path}, inserting ${docs.length} boundaries now...`)}`)
async.forEachSeries(docs, context.onBoundary.bind(null, file.type), cb)
async.forEach(docs, async.ensureAsync(context.onBoundary.bind(null, file.type)), cb)
})

stream.resume()
Expand Down

0 comments on commit f858072

Please sign in to comment.