-
Notifications
You must be signed in to change notification settings - Fork 563
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
fix: add jsdoc and do minor changes in utils.js #3550
Conversation
function parseKeepAliveTimeout (val) { | ||
const m = val.toString().match(KEEPALIVE_TIMEOUT_EXPR) | ||
const m = val.match(KEEPALIVE_TIMEOUT_EXPR) |
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.
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 |
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.
we can reuse the headersLength variable for the for loop
function parseRangeHeader (range) { | ||
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 |
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.
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) { |
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 obj[kListeners] is not null or undefined, then we know it is an array, so only do the steps if we have somthing set.
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
add jsdoc to the utils.js file to improve typings in other places.
also made minor changes, which i will comment