From d0b4a0cefdddae94721a41e0664a0fbd02e147d1 Mon Sep 17 00:00:00 2001 From: jonkrone Date: Mon, 18 Jun 2018 16:24:47 -0500 Subject: [PATCH] fix: do not destructure node callback results --- src/core/components/dag.js | 2 +- src/core/components/pin-set.js | 4 ++-- src/core/components/pin.js | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/components/dag.js b/src/core/components/dag.js index 2e8685305c..e43ea241f8 100644 --- a/src/core/components/dag.js +++ b/src/core/components/dag.js @@ -39,7 +39,7 @@ module.exports = function dag (self) { try { cid = new CID(cid) } catch (err) { - callback(err) + return callback(err) } } diff --git a/src/core/components/pin-set.js b/src/core/components/pin-set.js index 541b3eed49..f18a248604 100644 --- a/src/core/components/pin-set.js +++ b/src/core/components/pin-set.js @@ -74,9 +74,9 @@ exports = module.exports = function (dag) { seen[bs58Link] = true - dag.get(multihash, (err, { value }) => { + dag.get(multihash, (err, res) => { if (err) { return someCb(err) } - searchChildren(value, someCb) + searchChildren(res.value, someCb) }) }, cb) } diff --git a/src/core/components/pin.js b/src/core/components/pin.js index f276a87395..93f79a8e74 100644 --- a/src/core/components/pin.js +++ b/src/core/components/pin.js @@ -157,7 +157,7 @@ module.exports = function pin (self) { // persist updated pin sets to datastore flushPins((err, root) => { if (err) { return callback(err) } - return callback(null, results.map(key => ({hash: key}))) + return callback(null, results.map(hash => ({ hash }))) }) }) }) @@ -215,7 +215,7 @@ module.exports = function pin (self) { flushPins((err, root) => { if (err) { return callback(err) } self.log(`Removed pins: ${results}`) - return callback(null, results.map(key => ({hash: key}))) + return callback(null, results.map(hash => ({ hash }))) }) }) }) @@ -375,8 +375,9 @@ module.exports = function pin (self) { async.parallel([ cb => pinset.loadSet(pinRoot.value, types.recursive, cb), cb => pinset.loadSet(pinRoot.value, types.direct, cb) - ], (err, [rKeys, dKeys]) => { + ], (err, keys) => { if (err) { return callback(err) } + const [ rKeys, dKeys ] = keys directPins = new Set(dKeys.map(toB58String)) recursivePins = new Set(rKeys.map(toB58String))