File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 11var from2 = require ( 'from2' ) ;
2+ var extend = require ( 'extend' ) ;
23
34// jobs is an array of function(next)
45// returns a Stream that emits 2 data events per job
@@ -11,18 +12,16 @@ module.exports = function(jobs) {
1112 return from2 . obj ( function read ( size , next ) {
1213 if ( jobs . length <= 0 ) return this . push ( null ) ;
1314 var job = jobs . shift ( ) ;
14- this . push ( {
15+ var ctx = {
1516 job : job ,
16- totalJobs : totalJobs ,
17- jobIndex : jobIndex
18- } ) ;
17+ jobIndex : jobIndex ,
18+ totalJobs : totalJobs
19+ } ;
20+ this . push ( ctx ) ;
1921 job ( function ( err , data ) {
20- next ( err , {
21- job :job ,
22- totalJobs : totalJobs ,
23- jobIndex : jobIndex ++ ,
24- result : data
25- } ) ;
22+ ++ jobIndex ;
23+ if ( err ) extend ( err , ctx ) ;
24+ next ( err , extend ( { result : data } , ctx ) ) ;
2625 } ) ;
2726 } ) ;
2827} ;
Original file line number Diff line number Diff line change 1717 "author" :
" Jan Bölsche <[email protected] > (http://regular.codes)" ,
1818 "license" : " ISC" ,
1919 "dependencies" : {
20+ "extend" : " ^2.0.1" ,
2021 "from2" : " ^1.3.0"
2122 },
2223 "devDependencies" : {
You can’t perform that action at this time.
0 commit comments