Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
feat: update files to use async dag-pb api
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Oct 27, 2016
1 parent 813ab69 commit ad96d22
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/add-to-dagnode-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

0 comments on commit ad96d22

Please sign in to comment.