| 1086 | }; |
| 1087 | |
| 1088 | function pipeOnDrain(src, dest) { |
| 1089 | return function pipeOnDrainFunctionResult() { |
| 1090 | const state = src._readableState; |
| 1091 | |
| 1092 | // `ondrain` will call directly, |
| 1093 | // `this` maybe not a reference to dest, |
| 1094 | // so we use the real dest here. |
| 1095 | if (state.awaitDrainWriters === dest) { |
| 1096 | debug('pipeOnDrain', 1); |
| 1097 | state.awaitDrainWriters = null; |
| 1098 | } else if ((state[kState] & kMultiAwaitDrain) !== 0) { |
| 1099 | debug('pipeOnDrain', state.awaitDrainWriters.size); |
| 1100 | state.awaitDrainWriters.delete(dest); |
| 1101 | } |
| 1102 | |
| 1103 | if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) && |
| 1104 | (state[kState] & kDataListening) !== 0) { |
| 1105 | src.resume(); |
| 1106 | } |
| 1107 | }; |
| 1108 | } |
| 1109 | |
| 1110 | |
| 1111 | Readable.prototype.unpipe = function(dest) { |