alanshaw / alanshaw/abortable-iterator
Abort signal is ignored when iterable doesn't yield anything
- Lenguaje dominante
- TypeScript
- Estrellas
- 16
- Forks
- 7
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
The first test times out and the second passes:
```typescript
import { PassThrough } from 'stream';
import { source as makeSourceAbortable } from 'abortable-iterator';
test('Empty source', async () => {
const source = new PassThrough();
const abortController = new AbortController();
const abortableSource = makeSourceAbortable(source, abortController.signal, {
returnOnAbort: true,
});
setImmediate(() => abortController.abort());
for await (const chunk of abortableSource) {
throw new Error(`Shouldn't have got ${chunk}`);
}
});
test('Non-empty source', async () => {
const source = new PassThrough();
const abortController = new AbortController();
const abortableSource = makeSourceAbortable(source, abortController.signal, {
returnOnAbort: true,
});
setImmediate(() => {
source.write('foo');
abortController.abort();
});
for await (const chunk of abortableSource) {
expect(chunk).toBe('foo');
}
});
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.