-
Notifications
You must be signed in to change notification settings - Fork 171
Add basic tests for decodeArrayStream #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@ ## master #44 +/- ## ========================================== + Coverage 91.46% 93.59% +2.13% ========================================== Files 14 15 +1 Lines 808 828 +20 Branches 170 173 +3 ========================================== + Hits 739 775 +36 + Misses 49 28 -21 - Partials 20 25 +5
Continue to review full report at Codecov.
|
test/decodeArrayStream.test.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use assert.rejects()
https://nodejs.org/api/assert.html#assert_assert_rejects_asyncfn_error_message
You can find its usage in this repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Thanks!
BTW you can just return AsyncIterable from decodeAsync()
like this:
diff --git a/src/decodeAsync.ts b/src/decodeAsync.ts index d4bea9e..1773eb4 100644 --- a/src/decodeAsync.ts +++ b/src/decodeAsync.ts @@ -19,10 +19,10 @@ export async function decodeAsync( return decoder.decodeOneAsync(stream); } -export async function* decodeArrayStream( +export function decodeArrayStream( stream: AsyncIterable<Uint8Array | ArrayLike<number>>, options: DecodeAsyncOptions = defaultDecodeOptions, -) { +): AsyncIterable<unknown> { const decoder = new Decoder( options.extensionCodec, options.maxStrLength, @@ -32,7 +32,5 @@ export async function* decodeArrayStream( options.maxExtLength, ); - for await (let item of decoder.decodeArrayStream(stream)) { - yield item; - } + return decoder.decodeArrayStream(stream); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay! Approved.
@gfx just few of basic tests for decodeArrayStream #42