From 18f537ee03ce73f3fd953be51b7f67448a45665c Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 13 Jan 2022 13:49:54 +0000 Subject: [PATCH] fix: export reader type (#8) Export type so we can pass argument to `.next` --- src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 9632482..15ea9a6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,12 @@ import BufferList from 'bl/BufferList.js' import type { Source } from 'it-stream-types' +export interface Reader extends AsyncGenerator { + next: (...args: [] | [number]) => Promise> +} + export function reader (source: Source) { - const reader = (async function * (): AsyncGenerator { + const reader: Reader = (async function * (): AsyncGenerator { // @ts-expect-error first yield in stream is ignored let bytes: number | undefined = yield // Allows us to receive 8 when reader.next(8) is called let bl = new BufferList()