Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: reuse createAddPullStream to avoid code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Oct 20, 2017
1 parent 4daa0ad commit 3038452
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/core/components/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,9 @@ module.exports = function files (self) {
return callback(new Error('Invalid arguments, data must be an object, Buffer or readable stream'))
}

let total = 0
let prog = options.progress || (() => {})
const progress = (bytes) => {
total += bytes
prog(total)
}

options.progress = progress
pull(
pull.values(normalizeContent(data)),
importer(self._ipldResolver, options),
pull.asyncMap(prepareFile.bind(null, self, options)),
pull.values([data]),
createAddPullStream(options),
sort((a, b) => {
if (a.path < b.path) return 1
if (a.path > b.path) return -1
Expand Down

0 comments on commit 3038452

Please sign in to comment.