| 133 | } |
| 134 | |
| 135 | async function testShareAbortSignal() { |
| 136 | const ac = new AbortController(); |
| 137 | const reason = new Error('share aborted'); |
| 138 | const enc = new TextEncoder(); |
| 139 | async function* source() { |
| 140 | yield [enc.encode('a')]; |
| 141 | yield [enc.encode('b')]; |
| 142 | } |
| 143 | const shared = share(source(), { |
| 144 | highWaterMark: 1, |
| 145 | backpressure: 'block', |
| 146 | signal: ac.signal, |
| 147 | }); |
| 148 | const fast = shared.pull()[Symbol.asyncIterator](); |
| 149 | shared.pull(); |
| 150 | |
| 151 | await fast.next(); |
| 152 | const read = fast.next(); |
| 153 | const rejected = assert.rejects(read, (error) => error === reason); |
| 154 | ac.abort(reason); |
| 155 | |
| 156 | await rejected; |
| 157 | } |
| 158 | |
| 159 | async function testShareAbortSignalWhileSourcePullPending() { |
| 160 | const ac = new AbortController(); |