Skip to content

Conversation

@Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Sep 4, 2024

add jsdoc to the utils.js file to improve typings in other places.

also made minor changes, which i will comment

*/
function parseKeepAliveTimeout (val) {
const m = val.toString().match(KEEPALIVE_TIMEOUT_EXPR)
const m = val.match(KEEPALIVE_TIMEOUT_EXPR)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

parseKeepAliveTimeout gets according to my analysis always a string, so we can avoid the toString() call

function parseRawHeaders (headers) {
const len = headers.length
const ret = new Array(len)
const headersLength = headers.length
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can reuse the headersLength variable for the for loop

if (range == null || range === '') return { start: 0, end: null, size: null }

const m = range ? range.match(/^bytes (\d+)-(\d+)\/(\d+)?$/) : null
const m = range ? range.match(rangeHeaderRegex) : null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

extracted the range regex for better perf

function removeAllListeners (obj) {
for (const [name, listener] of obj[kListeners] ?? []) {
obj.removeListener(name, listener)
if (obj[kListeners] != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if obj[kListeners] is not null or undefined, then we know it is an array, so only do the steps if we have somthing set.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@Uzlopak Uzlopak merged commit 61a4b69 into nodejs:main Sep 5, 2024
@Uzlopak Uzlopak deleted the jsdoc-utils branch September 5, 2024 11:12
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
This was referenced Dec 16, 2024
@github-actions github-actions bot mentioned this pull request Mar 12, 2025
@github-actions github-actions bot mentioned this pull request May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants