Created
September 17, 2016 16:58
-
-
Save victorb/1414333a84479433aa9b292dae73274c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function addPipeline (index, addStream, list) { | |
pull( | |
zip( | |
pull.values(list), | |
pull( | |
pull.values(list), | |
paramap(fs.stat.bind(fs), 50) | |
) | |
), | |
pull.map((pair) => ({ | |
path: pair[0], | |
isDirectory: pair[1].isDirectory() | |
})), | |
pull.filter((file) => !file.isDirectory), | |
pull.map((file) => ({ | |
path: file.path.substring(index, file.path.length), | |
content: fs.createReadStream(file.path) | |
})), | |
addStream, | |
pull.map((file) => ({ | |
hash: file.hash, | |
path: file.path | |
})), | |
pull.collect((err, added) => { | |
if (err) { | |
throw err | |
} | |
sortBy(added, 'path') | |
.reverse() | |
.map((file) => `added ${file.hash} ${file.path}`) | |
.forEach((msg) => console.log(msg)) | |
}) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment