add hw2
This commit is contained in:
		
							
								
								
									
										38
									
								
								node_modules/pino/lib/worker-pipeline.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								node_modules/pino/lib/worker-pipeline.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| 'use strict' | ||||
|  | ||||
| const EE = require('events') | ||||
| const loadTransportStreamBuilder = require('./transport-stream') | ||||
| const { pipeline, PassThrough } = require('stream') | ||||
|  | ||||
| // This file is not checked by the code coverage tool, | ||||
| // as it is not reliable. | ||||
|  | ||||
| /* istanbul ignore file */ | ||||
|  | ||||
| module.exports = async function ({ targets }) { | ||||
|   const streams = await Promise.all(targets.map(async (t) => { | ||||
|     const fn = await loadTransportStreamBuilder(t.target) | ||||
|     const stream = await fn(t.options) | ||||
|     return stream | ||||
|   })) | ||||
|   const ee = new EE() | ||||
|  | ||||
|   const stream = new PassThrough({ | ||||
|     autoDestroy: true, | ||||
|     destroy (_, cb) { | ||||
|       ee.on('error', cb) | ||||
|       ee.on('closed', cb) | ||||
|     } | ||||
|   }) | ||||
|  | ||||
|   pipeline(stream, ...streams, function (err) { | ||||
|     if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { | ||||
|       ee.emit('error', err) | ||||
|       return | ||||
|     } | ||||
|  | ||||
|     ee.emit('closed') | ||||
|   }) | ||||
|  | ||||
|   return stream | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 nik
					nik