Skip to content

Commit

Permalink
fix: export reader type (#8)
Browse files Browse the repository at this point in the history
Export type so we can pass argument to `.next`
  • Loading branch information
achingbrain authored Jan 13, 2022
1 parent 6fee456 commit 18f537e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import BufferList from 'bl/BufferList.js'
import type { Source } from 'it-stream-types'

export interface Reader extends AsyncGenerator<BufferList, void, any> {
next: (...args: [] | [number]) => Promise<IteratorResult<BufferList, void>>
}

export function reader (source: Source<Uint8Array>) {
const reader = (async function * (): AsyncGenerator<BufferList, void, any> {
const reader: Reader = (async function * (): AsyncGenerator<BufferList, void, any> {
// @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()
Expand Down

0 comments on commit 18f537e

Please sign in to comment.