0.0.9 • Published 9 years ago
mystreams v0.0.9
MyStreams
npm install mystreams
var { streamAsyncCall, transform, splitArray, enrich, groupBy, splitKeyValue } = require('mystreams');
var git = function(cmd, parsers, cb) {
//...
};
streamAsyncCall(
git, // async function
`diff-tree --raw -r ${argv.tree1} ${argv.tree2}${argv.filter ? ' -- \'' + argv.filter + '\'' : ''}`, //arg1
[git.mappers.parseDiffOutput] //arg2
).pipe(
splitArray()
).pipe(
enrich(
[x => !!x.newSha, x => git.getBlob.bind(git, x.newSha), (err, v, x) => (x.newBlob = v, x)],
[x => !!x.oldSha, x => git.getBlob.bind(git, x.oldSha), (err, v, x) => (x.oldBlob = v, x)]
)
).pipe(
// ...
).pipe(
groupBy(x => x.key, v => v.blob)
).pipe(
splitKeyValue()
).pipe(
enrich([ x => true, x => git.makeTree.bind(git, x.value), (err, v, x) => (x.sha = v, x) ])
).pipe(
groupBy(x => 'root', v => ({name: v.key, type: 'tree', sha: v.sha}))
).pipe(
enrich([ x => true, x => git.makeTree.bind(git, x.root), (err, v, x) => (x.sha = v, x) ])
).pipe(
transform(x => x.sha)
).pipe(
process.stdout
);