This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c744dc
commit 7437577
Showing
3 changed files
with
35 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
'use strict' | ||
|
||
const map = require('async/map') | ||
const waterfall = require('async/waterfall') | ||
|
||
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) => waterfall([ | ||
(cb) => getDagNode(send, entry.Hash, cb), | ||
(node, cb) => node.size((err, size) => { | ||
if (err) { | ||
return next(err) | ||
return cb(err) | ||
} | ||
var obj = { | ||
|
||
next(null, { | ||
path: entry.Name, | ||
hash: entry.Hash, | ||
size: node.size() | ||
} | ||
next(null, obj) | ||
size: size | ||
}) | ||
}) | ||
}, function (err, res) { | ||
done(err, res) | ||
}) | ||
], next), done) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters