Skip to content

Commit

Permalink
chore: improve jsdoc of lib/core/constants.js (#3570)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Sep 10, 2024
1 parent 6ae5de2 commit 0b48868
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/core/constants.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict'

/** @type {Record<string, string | undefined>} */
const headerNameLowerCasedRecord = {}

// https://developer.mozilla.org/docs/Web/HTTP/Headers
const wellknownHeaderNames = [
/**
* @see https://developer.mozilla.org/docs/Web/HTTP/Headers
*/
const wellknownHeaderNames = /** @type {const} */ ([
'Accept',
'Accept-Encoding',
'Accept-Language',
Expand Down Expand Up @@ -100,7 +99,13 @@ const wellknownHeaderNames = [
'X-Powered-By',
'X-Requested-With',
'X-XSS-Protection'
]
])

/** @type {Record<typeof wellknownHeaderNames[number]|Lowercase<typeof wellknownHeaderNames[number]>, string>} */
const headerNameLowerCasedRecord = {}

// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`.
Object.setPrototypeOf(headerNameLowerCasedRecord, null)

for (let i = 0; i < wellknownHeaderNames.length; ++i) {
const key = wellknownHeaderNames[i]
Expand All @@ -109,9 +114,6 @@ for (let i = 0; i < wellknownHeaderNames.length; ++i) {
lowerCasedKey
}

// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`.
Object.setPrototypeOf(headerNameLowerCasedRecord, null)

module.exports = {
wellknownHeaderNames,
headerNameLowerCasedRecord
Expand Down

0 comments on commit 0b48868

Please sign in to comment.