From e6a1a427673fc2cc53b2cdc8a49addd1d4613443 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 19 Apr 2023 11:03:43 +0200 Subject: [PATCH] fix: accept source as a sink input type To make it a bit more flexible --- package.json | 1 + src/index.ts | 4 ++-- test/index.spec.ts | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b9ea411..4cf07aa 100644 --- a/package.json +++ b/package.json @@ -153,6 +153,7 @@ ] }, "scripts": { + "clean": "aegir clean", "lint": "aegir lint", "dep-check": "aegir dep-check dist/src/**/*.js dist/test/**/*.js", "build": "tsc", diff --git a/src/index.ts b/src/index.ts index 5d2fb0e..13a8735 100644 --- a/src/index.ts +++ b/src/index.ts @@ -139,11 +139,11 @@ export function abortableSource (source: Source, signal: AbortSignal, opt return abortable() } -export function abortableSink > (sink: Sink, R>, signal: AbortSignal, options?: Options): Sink, R> { +export function abortableSink > (sink: Sink, R>, signal: AbortSignal, options?: Options): Sink, R> { return (source: Source) => sink(abortableSource(source, signal, options)) } -export function abortableDuplex > (duplex: Duplex, AsyncIterable, RSink>, signal: AbortSignal, options?: Options): Duplex, AsyncIterable, RSink> { +export function abortableDuplex > (duplex: Duplex, Source, RSink>, signal: AbortSignal, options?: Options): Duplex, Source, RSink> { return { sink: abortableSink(duplex.sink, signal, { ...options, diff --git a/test/index.spec.ts b/test/index.spec.ts index dbec5b4..0bddbb4 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -175,7 +175,7 @@ describe('abortable-iterator', () => { it('should abort a duplex used as a source', async () => { const controller = new AbortController() - const duplex: Duplex> = { + const duplex: Duplex, Source> = { source: forever(), sink: async (source) => { await drain(source) } } @@ -192,7 +192,7 @@ describe('abortable-iterator', () => { it('should abort a duplex used as a transform', async () => { const controller = new AbortController() - const duplex: Duplex> = { + const duplex: Duplex, Source> = { source: forever(), sink: drain } @@ -210,7 +210,7 @@ describe('abortable-iterator', () => { it('should abort a duplex used as a sink', async () => { const controller = new AbortController() - const duplex: Duplex> = { + const duplex: Duplex, Source> = { source: forever(), sink: drain }