Skip to content

typings: add typing for string decoder - #38229

Merged
aduh95 merged 4 commits into
nodejs:masterfrom
Ayase-252:feature/typing-lib-internal-cipher
Dec 30, 2021
Merged

typings: add typing for string decoder#38229
aduh95 merged 4 commits into
nodejs:masterfrom
Ayase-252:feature/typing-lib-internal-cipher

Conversation

@Ayase-252

Copy link
Copy Markdown
Member

This PR adds some JSDoc typings for internal/string_decoder.

Screenshots from my VS code:

normalizeEncoding
Screen Shot 2021-04-13 at 23 35 26

StringDecoder
Screen Shot 2021-04-13 at 23 36 31

StringDecoder.prototype.write
Screen Shot 2021-04-13 at 23 37 00

StringDecoder.prototype.end
Screen Shot 2021-04-13 at 23 38 24

StringDecoder.prototype.text
Screen Shot 2021-04-13 at 23 37 34

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. string_decoder Issues and PRs related to the string_decoder subsystem. labels Apr 13, 2021

@Ayase-252Ayase-252 left a comment

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I know the line violates the maximum line length, but I couldn’t come up with a good idea to fix it. 🤔

Comment threadlib/string_decoder.js Outdated
/**
*
* @param {string} enc
* @returns {"utf8" | "utf16le" | "hex" | "ascii" | "base64" | "latin1" | "base64url"}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @returns{"utf8"|"utf16le"|"hex"|"ascii"|"base64"|"latin1"|"base64url"}
* @returns{"utf8"|"utf16le"|"hex"|"ascii"
*|"base64"|"latin1"|"base64url"}

What about this?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Thanks, it works

Co-authored-by: Michaël Zasso <targos@protonmail.com>
Comment threadlib/string_decoder.js

@marsonyamarsonya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would suggest adding function descriptions in the jsdoc comments.

Comment threadlib/string_decoder.js
};

/**
*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
*
*Returnsanyremaininginputstoredintheinternalbufferasastring.
*Afterend()iscalled,thestringDecoderobjectcanbereusedfornewinput.

Comment threadlib/string_decoder.js
// buffers into a series of JS strings without breaking apart multi-byte
// characters.
/**
*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move the above description inside the comment?

Comment threadlib/string_decoder.js
}

/**
*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
*
*Returnsadecodedstring,omittinganyincompletemultibyte
*charactersattheendoftheBuffer,orTypedArray,orDataView

@Ayase-252Ayase-252 changed the title typings: add typing for internal/string_decodertypings: add typing for string decoderApr 20, 2021
Co-authored-by: marsonya <akhil.marsonya27@gmail.com>

@marsonyamarsonya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mark optional params as such and assign default value using JSDoc conventions.

Kindly ignore it incase this is too much detailing. I know we don't want to duplicate the documentation here using JSDoc. I just feel that it would be important information for core developers to know whether a param is optional or not and what it's default value would be.

Comment threadlib/string_decoder.js Outdated
Comment threadlib/string_decoder.js Outdated
@Ayase-252

Copy link
Copy Markdown
MemberAuthor

Good idea, I will address optional arugment issue

Co-authored-by: Akhil Marsonya <akhil.marsonya27@gmail.com>
@MesteeryMesteery removed the needs-ci PRs that need a full CI run. label Oct 12, 2021

@aduh95aduh95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

RSLGTM

@aduh95aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Dec 30, 2021
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 30, 2021
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/38229
✔ Done loading data for nodejs/node/pull/38229
----------------------------------- PR info ------------------------------------
Title typings: add typing for string decoder (#38229)
Author Qingyu Deng (@Ayase-252)
Branch Ayase-252:feature/typing-lib-internal-cipher -> nodejs:master
Labels string_decoder, typings, commit-queue-squash
Commits 4
- typings: add typing for internal/string_decoder
- fixup: typings: add typing for internal/string_decoder
- fixup: add function description
- fixup: mark optional parameters
Committers 1
- Qingyu Deng PR-URL: https://github.com/nodejs/node/pull/38229
Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel ------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/38229
Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel --------------------------------------------------------------------------------
ℹ This PR was created on Tue, 13 Apr 2021 15:40:00 GMT
✔ Approvals: 2
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/38229#pullrequestreview-640365320
✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/38229#pullrequestreview-842115810
✔ Last GitHub CI successful
✖ No Jenkins CI runs detected
--------------------------------------------------------------------------------
✔ Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/1639087835

@nodejs-github-botnodejs-github-bot added the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Dec 30, 2021
@aduh95
aduh95 merged commit a100a93 into nodejs:masterDec 30, 2021
@aduh95

Copy link
Copy Markdown
Contributor

Landed in a100a93

targos pushed a commit that referenced this pull request Jan 14, 2022
PR-URL: #38229
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@targostargos mentioned this pull request Jan 16, 2022
danielleadams pushed a commit that referenced this pull request Jan 31, 2022
PR-URL: #38229
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
danielleadams pushed a commit that referenced this pull request Feb 1, 2022
PR-URL: #38229
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@danielleadamsdanielleadams mentioned this pull request Feb 1, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-failedAn error occurred while landing this pull request using GitHub Actions.commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.string_decoderIssues and PRs related to the string_decoder subsystem.typings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@Ayase-252@nodejs-github-bot@aduh95@jasnell@targos@marsonya@Mesteery