GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — string_decoder : support typed array or data view by BeniCheni · Pull Request #22562 · nodejs/node

Conversation

@BeniCheni

@BeniCheni BeniCheni commented Aug 28, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Fixes: #1826
Per this comment with the checklist, this PR attempts to help out the string_decoder scope from the check list. The PR supports explicitly TypedArray or DataView, insead of the original Uint8Array.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot nodejs-github-bot added the string_decoder Issues and PRs related to the string_decoder subsystem. label Aug 28, 2018
@BeniCheni BeniCheni changed the title String decoder typed array data view string_decoder : support typed array or data view Aug 28, 2018
@BeniCheni BeniCheni mentioned this pull request Aug 28, 2018
Accept ArrayBuffer (and typed array/data view?) anywhere Buffer is allowed in the API #1826
Closed
Trott
Trott reviewed Aug 28, 2018
View reviewed changes
Comment thread lib/string_decoder.js Outdated

@Trott Trott Aug 28, 2018

Copy link
Copy Markdown
Member

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.

While we're in here, does it make sense to alphabetize the list? Or is the existing ordering logical for other reasons?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@addaleax addaleax Aug 28, 2018

Copy link
Copy Markdown
Member

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.

I think the list makes sense in that Buffer will be the most common type of argument (by far), followed by TypedArrays.

I am not sure why ArrayBufferView is listed explicitly, since currently there are (afaik) only TypedArray and DataView ABVs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TimothyGu, BridgeAR, SirR4T, and BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 4 reactions
Trott
Trott reviewed Aug 28, 2018
View reviewed changes
Comment thread test/parallel/test-string-decoder.js Outdated

@Trott Trott Aug 28, 2018

Copy link
Copy Markdown
Member

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.

Why this change?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Aug 28, 2018

Copy link
Copy Markdown
Member

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.

To elaborate a bit: There's nothing in this change that breaks new Uint8Array() working in this context, so why is the test case being changed instead of a new test case being added?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Aug 28, 2018

Copy link
Copy Markdown
Member

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.

Shouldn't test cases be added for DataView and TypedArray? Do they even work properly? No code has been added in this PR to alter how they work with string_decoder. Were they working already or something?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BeniCheni and addaleax reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

@BeniCheni BeniCheni Aug 28, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

I was working with the suggestion of this comment here:

[ ] string_decoder
This list is for TypedArray/DataView support only.

I was trying not to use Unit8Array. Hopefully I understood the #1826 correctly.

If this Unit8Array doesn't need to change to Buffer to align with others, I can revert this change here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@devsnek devsnek Aug 31, 2018

Copy link
Copy Markdown
Member

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.

Buffer extends Uint8Array, I don't think this changed anything.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Trott
Trott reviewed Aug 28, 2018
View reviewed changes
Comment thread lib/string_decoder.js Outdated

@Trott Trott Aug 28, 2018

Copy link
Copy Markdown
Member

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.

Why is Uint8Array being removed here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax and BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

@BeniCheni BeniCheni Aug 28, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

From the suggestion of this comment in #1826, "string_decoder" seems to be on the list TypedArray/DataView support only. After viewing the fs PR and the child_process, I just gave my best attempt to follow the "idea" to handle string_decode.

Please let me know if I misunderstood too much off from the context of the checklist & goals from the comment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@addaleax addaleax Aug 28, 2018

Copy link
Copy Markdown
Member

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.

I think this is okay and somewhat consistent with how we handle it elsewhere

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@SirR4T SirR4T Aug 28, 2018

Copy link
Copy Markdown

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.

Hi @BeniCheni , I think broadly we can categorize the changes for these PRs into:

  1. adding missing tests, for TypedArrays and DataViews wherever only Buffers or Uint8Arrays were tested earlier
  2. Updating code to work with these new types, where necessary(should mostly involve only JS side of things, in lib and maybe lib/internal)
  3. Updating documentation to reflect these changes.

Here, your PR is updating the errors being thrown, but is neither adding test cases nor adding functionality to work with the TypedArrays or DataViews. Please note, it might well be the case that string_decoder already works for these, but adding test cases is a way of validation for the same. Hope that helps!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@BeniCheni BeniCheni Aug 28, 2018

Copy link
Copy Markdown
Contributor Author

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.

🙏 for the collective reviews. Will analyze & update accordingly.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
BridgeAR
BridgeAR approved these changes Aug 31, 2018
View reviewed changes

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

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.

LGTM when ArrayBufferView is removed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BeniCheni

BeniCheni commented Sep 1, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@ Trott: Shouldn't test cases be added for DataView and TypedArray?
@ SirR4T: adding missing tests, for TypedArrays and DataViews

Researched & wrote tests to cover TypedArray & DataView.

@ Trott: Why is Uint8Array being removed here?
@ devsnek: Buffer extends Uint8Array, I don't think this changed anything.

Researched more and updated to revert the previously incorrect removal of Uint8Array.

@ addaleax: I am not sure why ArrayBufferView is listed explicitly,
@ BridgeAR: LGTM when ArrayBufferView is removed.

Removed any context of ArrayBufferView in string_decoder source per suggestion.


Also confirmed if any context needed to update in string_decoder.md doc, but didn't find any necessary edit. Please suggest if I miss anything in the string_decoder.md doc. Please review again.

SirR4T reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR
BridgeAR approved these changes Sep 1, 2018
View reviewed changes

@BridgeAR BridgeAR left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Reconfirming my LG

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SirR4T

SirR4T commented Sep 1, 2018

Copy link
Copy Markdown

Hi @BeniCheni , thanks for updating the tests! I think we could also update string_decoder.md, specifically for the .end() and the .write() function documentations, since they accept not just buffers, but other types too.

BridgeAR and BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BeniCheni

BeniCheni commented Sep 1, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Hi @SirR4T, updated doc per your suggestion.

Notice the last CI instance failed with just a doc change in the commit. Awaiting to get help/advice from other reviewers to validate the failed CI instance.

Thoughts, any reviewer(s)?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SirR4T

SirR4T commented Sep 1, 2018

Copy link
Copy Markdown

Hi @BeniCheni , doc changes look good to me, thanks!

But as I'm myself a new enough contributor here, I'll refrain from approving PRs, in deference to someone with more review experience.

As for the CI failure, it doesn't seem related to your changes, but instead looks like a certificate failure from npm. This may or may not be related to npm's current issue at the time of this post.

BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax approved these changes Sep 2, 2018
View reviewed changes
@addaleax

addaleax commented Sep 2, 2018

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-pull-request/16942/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 2, 2018
@addaleax

addaleax commented Sep 2, 2018

Copy link
Copy Markdown
Member

New CI: https://ci.nodejs.org/job/node-test-pull-request/16953/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Sep 2, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Resume CI: https://ci.nodejs.org/job/node-test-pull-request/16971/ (:heavy_check_mark:)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

trivikr
trivikr approved these changes Sep 4, 2018
View reviewed changes
TimothyGu
TimothyGu reviewed Sep 5, 2018
View reviewed changes
Comment thread test/parallel/test-string-decoder.js Outdated

@TimothyGu TimothyGu Sep 5, 2018

Copy link
Copy Markdown
Member

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.

I'd prefer this test use getArrayBufferViews() to cover all possible TypedArray types and DataView. An example usage of this function by @SirR4T is

node/test/parallel/test-fs-write-file-typedarrays.js

Lines 24 to 31 in be5e396

for (const expectView of common.getArrayBufferViews(inputBuffer)) {
console.log('Sync test for ', expectView[Symbol.toStringTag]);
fs.writeFileSync(filename, expectView);
assert.strictEqual(
fs.readFileSync(filename, 'utf8'),
inputBuffer.toString('utf8')
);
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@BeniCheni

BeniCheni commented Sep 5, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@ TimothyGu:
I'd prefer this test use getArrayBufferViews() to cover all possible TypedArray types and DataView.

Hi, @TimothyGu. Updated to use the common getArrayBufferViews util to cover possible types. Please review at convenience? Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Sep 10, 2018
View reviewed changes
Comment thread test/parallel/test-string-decoder.js Outdated

@jasnell jasnell Sep 10, 2018

Copy link
Copy Markdown
Member

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.

If the console.log() statement is part of the test, please add a comment indicating such. If it is not, I'd prefer to use a comment instead of having the extraneous console output.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BeniCheni reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
BeniCheni added 7 commits September 10, 2018 23:48
@BeniCheni
string_decoder: support typed array or data view
8f14d9c
Fixes: #1826
@BeniCheni
string_decoder: update code format for ERR_INVALID_ARG_TYPE code area
7505b48
Fixes: #1826
@BeniCheni
string_decoder: update source & tests for TypedArray & DataView per r…
3a25c6e
…eviews

Fixes: #1826
@BeniCheni
doc: update .end & .write string_decoder.md
9057575
Refs: #22562 (comment)
@BeniCheni
test: update string-decoder tests w. ArrayBufferView
62393c0
@BeniCheni
test: shorten test message in string-decoder tests w. ArrayBufferView
5fb3198
@BeniCheni
test: remove console log message from string_decoder's ArrayBufferVie…
510ac79
…w tests

Refs: #22562 (comment)
@BeniCheni

BeniCheni commented Sep 11, 2018

Copy link
Copy Markdown
Contributor Author

@ jasnell
If the console.log() statement is part of the test, please add a comment indicating such. If it is not, I'd prefer to use a comment instead of having the extraneous console output.

Hello @jasnell,
I've checked & removed the unneeded console log message from the string_decode test code. Please review at convenience. Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BeniCheni

BeniCheni commented Sep 14, 2018

Copy link
Copy Markdown
Contributor Author

Ping/Dear reviewers,

Would you mind helping to guide this “author ready” PR to landing?

(Made all suggested updates according to previous review comments; thanks!)

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Sep 14, 2018

Copy link
Copy Markdown
Member

New CI: https://ci.nodejs.org/job/node-test-pull-request/17187/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Sep 17, 2018

Copy link
Copy Markdown
Member

Landed in e2325bc

SirR4T and BeniCheni reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax closed this Sep 17, 2018
addaleax pushed a commit that referenced this pull request Sep 17, 2018
@BeniCheni @addaleax
string_decoder: support typed array or data view
e2325bc
Refs: #1826
PR-URL: #22562
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@BeniCheni
BeniCheni deleted the string-decoder-typed-array-data-view branch September 18, 2018 02:56
targos pushed a commit that referenced this pull request Sep 18, 2018
@BeniCheni @targos
string_decoder: support typed array or data view
ac34f11
Refs: #1826
PR-URL: #22562
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@targos targos mentioned this pull request Sep 18, 2018
Release proposal: v10.11.0 #22932
Merged
targos pushed a commit that referenced this pull request Sep 19, 2018
@BeniCheni @targos
string_decoder: support typed array or data view
c17ba24
Refs: #1826
PR-URL: #22562
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Sep 20, 2018
@BeniCheni @targos
string_decoder: support typed array or data view
a10d03d
Refs: #1826
PR-URL: #22562
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell left review comments
@Trott Trott Trott left review comments
@addaleax addaleax addaleax approved these changes
@BridgeAR BridgeAR BridgeAR approved these changes
@trivikr trivikr trivikr approved these changes
+3 more reviewers
@TimothyGu TimothyGu TimothyGu left review comments
@SirR4T SirR4T SirR4T left review comments
@devsnek devsnek devsnek left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. string_decoder Issues and PRs related to the string_decoder subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@BeniCheni @SirR4T @addaleax @jasnell @Trott @TimothyGu @devsnek @BridgeAR @trivikr @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.