Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
sergeyzenchenko merged 2 commits into msgpack:master from sergeyzenchenko:master
May 30, 2019

Conversation

Copy link
Collaborator

@sergeyzenchenko sergeyzenchenko commented May 30, 2019

@gfx just few of basic tests for decodeArrayStream #42

Copy link

codecov-io commented May 30, 2019
edited
Loading

Codecov Report

Merging #44 into master will increase coverage by 2.13%.
The diff coverage is n/a.

Impacted file tree graph

@@ 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
Impacted Files Coverage Δ
src/index.ts 100% <0%> (ø) ⬆️
src/utils/stream.ts 26.66% <0%> (ø)
src/Decoder.ts 96.42% <0%> (+7.46%) ⬆️
src/decodeAsync.ts 100% <0%> (+33.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e3f706...1bc03a7. Read the comment docs.

error = e;
}

assert.notStrictEqual(error, null);
Copy link
Member

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.

Copy link
Collaborator Author

@sergeyzenchenko sergeyzenchenko May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

gfx commented May 30, 2019
edited
Loading

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);
 }

Copy link
Collaborator Author

@gfx duh :) I will fix it in PR for decodeStream #46

Copy link
Member

@gfx gfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay! Approved.

@gfx gfx mentioned this pull request May 30, 2019
@sergeyzenchenko sergeyzenchenko merged commit 9fd6111 into msgpack:master May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@gfx gfx gfx approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /