Skip to content

Commit 18f537e

Browse files
authored
fix: export reader type (#8)
Export type so we can pass argument to `.next`
1 parent 6fee456 commit 18f537e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import BufferList from 'bl/BufferList.js'
22
import type { Source } from 'it-stream-types'
33

4+
export interface Reader extends AsyncGenerator<BufferList, void, any> {
5+
next: (...args: [] | [number]) => Promise<IteratorResult<BufferList, void>>
6+
}
7+
48
export function reader (source: Source<Uint8Array>) {
5-
const reader = (async function * (): AsyncGenerator<BufferList, void, any> {
9+
const reader: Reader = (async function * (): AsyncGenerator<BufferList, void, any> {
610
// @ts-expect-error first yield in stream is ignored
711
let bytes: number | undefined = yield // Allows us to receive 8 when reader.next(8) is called
812
let bl = new BufferList()

0 commit comments

Comments
 (0)