| | | |
Offset 452, 118 lines modified | Offset 452, 127 lines modified |
452 | ············}]); | 452 | ············}]); |
| |
453 | ············return·BufferList; | 453 | ············return·BufferList; |
454 | ········}(); | 454 | ········}(); |
455 | ····return·buffer_list; | 455 | ····return·buffer_list; |
456 | } | 456 | } |
| |
457 | function·destroy(err,·cb)·{ | |
458 | ····var·_this·=·this; | 457 | var·destroy_1; |
| 458 | var·hasRequiredDestroy; |
| |
459 | ····var·readableDestroyed·=·this._readableState·&&·this._readableState.destroyed; | |
460 | ····var·writableDestroyed·=·this._writableState·&&·this._writableState.destroyed; | 459 | function·requireDestroy()·{ |
| 460 | ····if·(hasRequiredDestroy)·return·destroy_1; |
| 461 | ····hasRequiredDestroy·=·1; |
| |
| 462 | ····function·destroy(err,·cb)·{ |
| 463 | ········var·_this·=·this; |
| |
| 464 | ········var·readableDestroyed·=·this._readableState·&&·this._readableState.destroyed; |
| 465 | ········var·writableDestroyed·=·this._writableState·&&·this._writableState.destroyed; |
| |
461 | ····if·(readableDestroyed·||·writableDestroyed)·{ | 466 | ········if·(readableDestroyed·||·writableDestroyed)·{ |
462 | ········if·(cb)·{ | 467 | ············if·(cb)·{ |
463 | ············cb(err); | 468 | ················cb(err); |
464 | ········}·else·if·(err)·{ | 469 | ············}·else·if·(err)·{ |
465 | ············if·(!this._writableState)·{ | 470 | ················if·(!this._writableState)·{ |
466 | ················process.nextTick(emitErrorNT,·this,·err); | 471 | ····················process.nextTick(emitErrorNT,·this,·err); |
467 | ············}·else·if·(!this._writableState.errorEmitted)·{ | 472 | ················}·else·if·(!this._writableState.errorEmitted)·{ |
468 | ················this._writableState.errorEmitted·=·true; | 473 | ····················this._writableState.errorEmitted·=·true; |
469 | ················process.nextTick(emitErrorNT,·this,·err); | 474 | ····················process.nextTick(emitErrorNT,·this,·err); |
| 475 | ················} |
470 | ············} | 476 | ············} |
471 | ········} | |
| |
472 | ········return·this; | 477 | ············return·this; |
473 | ····}·//·we·set·destroyed·to·true·before·firing·error·callbacks·in·order | 478 | ········}·//·we·set·destroyed·to·true·before·firing·error·callbacks·in·order |
474 | ····//·to·make·it·re-entrance·safe·in·case·destroy()·is·called·within·callbacks | 479 | ········//·to·make·it·re-entrance·safe·in·case·destroy()·is·called·within·callbacks |
| |
| |
475 | ····if·(this._readableState)·{ | 480 | ········if·(this._readableState)·{ |
476 | ········this._readableState.destroyed·=·true; | 481 | ············this._readableState.destroyed·=·true; |
477 | ····}·//·if·this·is·a·duplex·stream·mark·the·writable·part·as·destroyed·as·well | 482 | ········}·//·if·this·is·a·duplex·stream·mark·the·writable·part·as·destroyed·as·well |
| |
| |
478 | ····if·(this._writableState)·{ | 483 | ········if·(this._writableState)·{ |
479 | ········this._writableState.destroyed·=·true; | 484 | ············this._writableState.destroyed·=·true; |
480 | ····} | 485 | ········} |
| |
481 | ····this._destroy(err·||·null,·function(err)·{ | 486 | ········this._destroy(err·||·null,·function(err)·{ |
482 | ········if·(!cb·&&·err)·{ | 487 | ············if·(!cb·&&·err)·{ |
483 | ············if·(!_this._writableState)·{ | 488 | ················if·(!_this._writableState)·{ |
484 | ················process.nextTick(emitErrorAndCloseNT,·_this,·err); | 489 | ····················process.nextTick(emitErrorAndCloseNT,·_this,·err); |
485 | ············}·else·if·(!_this._writableState.errorEmitted)·{ | 490 | ················}·else·if·(!_this._writableState.errorEmitted)·{ |
486 | ················_this._writableState.errorEmitted·=·true; | 491 | ····················_this._writableState.errorEmitted·=·true; |
487 | ················process.nextTick(emitErrorAndCloseNT,·_this,·err); | 492 | ····················process.nextTick(emitErrorAndCloseNT,·_this,·err); |
| 493 | ················}·else·{ |
| 494 | ····················process.nextTick(emitCloseNT,·_this); |
| 495 | ················} |
| 496 | ············}·else·if·(cb)·{ |
| 497 | ················process.nextTick(emitCloseNT,·_this); |
| 498 | ················cb(err); |
488 | ············}·else·{ | 499 | ············}·else·{ |
489 | ················process.nextTick(emitCloseNT,·_this); | 500 | ················process.nextTick(emitCloseNT,·_this); |
490 | ············} | 501 | ············} |
491 | ········}·else·if·(cb)·{ | |
492 | ············process.nextTick(emitCloseNT,·_this); | |
493 | ············cb(err); | |
494 | ········}·else·{ | |
495 | ············process.nextTick(emitCloseNT,·_this); | |
496 | ········} | 502 | ········}); |
497 | ····}); | |
| |
498 | ····return·this; | 503 | ········return·this; |
499 | } | 504 | ····} |
| |
500 | function·emitErrorAndCloseNT(self,·err)·{ | 505 | ····function·emitErrorAndCloseNT(self,·err)·{ |
501 | ····emitErrorNT(self,·err); | 506 | ········emitErrorNT(self,·err); |
502 | ····emitCloseNT(self); | 507 | ········emitCloseNT(self); |
503 | } | 508 | ····} |
| |
504 | function·emitCloseNT(self)·{ | 509 | ····function·emitCloseNT(self)·{ |
505 | ····if·(self._writableState·&&·!self._writableState.emitClose)·return; | 510 | ········if·(self._writableState·&&·!self._writableState.emitClose)·return; |
506 | ····if·(self._readableState·&&·!self._readableState.emitClose)·return; | 511 | ········if·(self._readableState·&&·!self._readableState.emitClose)·return; |
507 | ····self.emit('close'); | 512 | ········self.emit('close'); |
508 | } | 513 | ····} |
| |
509 | function·undestroy()·{ | 514 | ····function·undestroy()·{ |
510 | ····if·(this._readableState)·{ | 515 | ········if·(this._readableState)·{ |
511 | ········this._readableState.destroyed·=·false; | 516 | ············this._readableState.destroyed·=·false; |
512 | ········this._readableState.reading·=·false; | 517 | ············this._readableState.reading·=·false; |
513 | ········this._readableState.ended·=·false; | 518 | ············this._readableState.ended·=·false; |
514 | ········this._readableState.endEmitted·=·false; | 519 | ············this._readableState.endEmitted·=·false; |
515 | ····} | 520 | ········} |
| |
516 | ····if·(this._writableState)·{ | 521 | ········if·(this._writableState)·{ |
517 | ········this._writableState.destroyed·=·false; | 522 | ············this._writableState.destroyed·=·false; |
518 | ········this._writableState.ended·=·false; | 523 | ············this._writableState.ended·=·false; |
519 | ········this._writableState.ending·=·false; | 524 | ············this._writableState.ending·=·false; |
520 | ········this._writableState.finalCalled·=·false; | 525 | ············this._writableState.finalCalled·=·false; |
521 | ········this._writableState.prefinished·=·false; | 526 | ············this._writableState.prefinished·=·false; |
522 | ········this._writableState.finished·=·false; | 527 | ············this._writableState.finished·=·false; |
523 | ········this._writableState.errorEmitted·=·false; | 528 | ············this._writableState.errorEmitted·=·false; |
| 529 | ········} |
524 | ····} | 530 | ····} |
525 | } | |
| |
526 | function·emitErrorNT(self,·err)·{ | 531 | ····function·emitErrorNT(self,·err)·{ |
527 | ····self.emit('error',·err); | 532 | ········self.emit('error',·err); |
528 | } | 533 | ····} |
| |
529 | function·errorOrDestroy(stream,·err)·{ | 534 | ····function·errorOrDestroy(stream,·err)·{ |
530 | ····//·We·have·tests·that·rely·on·errors·being·emitted | 535 | ········//·We·have·tests·that·rely·on·errors·being·emitted |
531 | ····//·in·the·same·tick,·so·changing·this·is·semver·major. | 536 | ········//·in·the·same·tick,·so·changing·this·is·semver·major. |
532 | ····//·For·now·when·you·opt-in·to·autoDestroy·we·allow | 537 | ········//·For·now·when·you·opt-in·to·autoDestroy·we·allow |
533 | ····//·the·error·to·be·emitted·nextTick.·In·a·future | 538 | ········//·the·error·to·be·emitted·nextTick.·In·a·future |
534 | ····//·semver·major·update·we·should·change·the·default·to·this. | 539 | ········//·semver·major·update·we·should·change·the·default·to·this. |
535 | ····var·rState·=·stream._readableState; | 540 | ········var·rState·=·stream._readableState; |
536 | ····var·wState·=·stream._writableState; | 541 | ········var·wState·=·stream._writableState; |
537 | ····if·(rState·&&·rState.autoDestroy·||·wState·&&·wState.autoDestroy)·stream.destroy(err); | 542 | ········if·(rState·&&·rState.autoDestroy·||·wState·&&·wState.autoDestroy)·stream.destroy(err); |
538 | ····else·stream.emit('error',·err); | 543 | ········else·stream.emit('error',·err); |
539 | } | 544 | ····} |
| |
540 | var·destroy_1·=·{ | 545 | ····destroy_1·=·{ |
541 | ····destroy:·destroy, | 546 | ········destroy:·destroy, |
542 | ····undestroy:·undestroy, | 547 | ········undestroy:·undestroy, |
543 | ····errorOrDestroy:·errorOrDestroy | 548 | ········errorOrDestroy:·errorOrDestroy |
Max diff block lines reached; 3989/11335 bytes (35.19%) of diff not shown.
|