From ad96d228906d08310dc0ef804c42f751f8854600 Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 27 Oct 2016 13:08:53 +0200 Subject: [PATCH] feat: update files to use async dag-pb api --- src/add-to-dagnode-transform.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/add-to-dagnode-transform.js b/src/add-to-dagnode-transform.js index 32de7f698..5f2e65785 100644 --- a/src/add-to-dagnode-transform.js +++ b/src/add-to-dagnode-transform.js @@ -4,24 +4,29 @@ const map = require('async/map') const getDagNode = require('./get-dagnode') // transform { Hash: '...' } objects into { path: 'string', node: DAGNode } -module.exports = function (err, res, send, done) { +module.exports = (err, res, send, done) => { if (err) { return done(err) } - map(res, function map (entry, next) { - getDagNode(send, entry.Hash, function (err, node) { + map(res, (entry, next) => { + getDagNode(send, entry.Hash, (err, node) => { if (err) { return next(err) } - var obj = { - path: entry.Name, - hash: entry.Hash, - size: node.size() - } - next(null, obj) + node.size((err, size) => { + if (err) { + return next(err) + } + const obj = { + path: entry.Name, + hash: entry.Hash, + size: size + } + next(null, obj) + }) }) - }, function (err, res) { + }, (err, res) => { done(err, res) }) }