From 1d04f1416d38ef100adea00a27e37d779df3432e Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Thu, 26 Jul 2018 10:09:00 -0700 Subject: [PATCH] Parallelise calls to atos --- index.js | 25 +++++++++---------------- package.json | 1 + 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 812e09d..5b374fb 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,11 @@ +const fs = require('fs') +const os = require('os') +const path = require('path') const ChildProcess = require('child_process') + const electronDownload = require('electron-download') const extractZip = require('extract-zip') -const fs = require('fs') -const path = require('path') +const mapLimit = require('async/mapLimit') module.exports = (options, callback) => { const {version, quiet, file, force} = options @@ -13,23 +16,13 @@ module.exports = (options, callback) => { download({version, quiet, directory, force}, (error) => { if (error != null) return callback(error) - const symbols = [] - const symbolicateNextAddress = () => { - const address = addresses.shift() - if (address == null) return callback(null, symbols) - + mapLimit(addresses, os.cpus().length, (address, cb) => { if (address.line != null) { - symbols.push(address.line) - symbolicateNextAddress() + cb(null, address.line) } else { - symbolicate({directory, address}, (error, symbol) => { - if (error != null) return callback(error) - symbols.push(symbol) - symbolicateNextAddress() - }) + symbolicate({directory, address}, cb) } - } - symbolicateNextAddress() + }, callback) }) } diff --git a/package.json b/package.json index fe6f6eb..1dde7a8 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "author": "Kevin Sawicki", "license": "ISC", "dependencies": { + "async": "^2.6.1", "electron-download": "^4.0.0", "extract-zip": "^1.6.0", "yargs": "^6.6.0"