Skip to content

Commit

Permalink
jsdoc: add jsdoc to lib/web/fetch/constants.js (#3597) (#3710)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3d0ce67)

Co-authored-by: Aras Abbasi <[email protected]>
  • Loading branch information
github-actions[bot] and Uzlopak authored Oct 10, 2024
1 parent 24b9403 commit 5be8ebf
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions lib/web/fetch/constants.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
'use strict'

const corsSafeListedMethods = ['GET', 'HEAD', 'POST']
const corsSafeListedMethods = /** @type {const} */ (['GET', 'HEAD', 'POST'])
const corsSafeListedMethodsSet = new Set(corsSafeListedMethods)

const nullBodyStatus = [101, 204, 205, 304]
const nullBodyStatus = /** @type {const} */ ([101, 204, 205, 304])

const redirectStatus = [301, 302, 303, 307, 308]
const redirectStatus = /** @type {const} */ ([301, 302, 303, 307, 308])
const redirectStatusSet = new Set(redirectStatus)

// https://fetch.spec.whatwg.org/#block-bad-port
const badPorts = [
/**
* @see https://fetch.spec.whatwg.org/#block-bad-port
*/
const badPorts = /** @type {const} */ ([
'1', '7', '9', '11', '13', '15', '17', '19', '20', '21', '22', '23', '25', '37', '42', '43', '53', '69', '77', '79',
'87', '95', '101', '102', '103', '104', '109', '110', '111', '113', '115', '117', '119', '123', '135', '137',
'139', '143', '161', '179', '389', '427', '465', '512', '513', '514', '515', '526', '530', '531', '532',
'540', '548', '554', '556', '563', '587', '601', '636', '989', '990', '993', '995', '1719', '1720', '1723',
'2049', '3659', '4045', '4190', '5060', '5061', '6000', '6566', '6665', '6666', '6667', '6668', '6669', '6679',
'6697', '10080'
]

])
const badPortsSet = new Set(badPorts)

// https://w3c.github.io/webappsec-referrer-policy/#referrer-policies
const referrerPolicy = [
/**
* @see https://w3c.github.io/webappsec-referrer-policy/#referrer-policies
*/
const referrerPolicy = /** @type {const} */ ([
'',
'no-referrer',
'no-referrer-when-downgrade',
Expand All @@ -31,29 +34,31 @@ const referrerPolicy = [
'origin-when-cross-origin',
'strict-origin-when-cross-origin',
'unsafe-url'
]
])
const referrerPolicySet = new Set(referrerPolicy)

const requestRedirect = ['follow', 'manual', 'error']
const requestRedirect = /** @type {const} */ (['follow', 'manual', 'error'])

const safeMethods = ['GET', 'HEAD', 'OPTIONS', 'TRACE']
const safeMethods = /** @type {const} */ (['GET', 'HEAD', 'OPTIONS', 'TRACE'])
const safeMethodsSet = new Set(safeMethods)

const requestMode = ['navigate', 'same-origin', 'no-cors', 'cors']
const requestMode = /** @type {const} */ (['navigate', 'same-origin', 'no-cors', 'cors'])

const requestCredentials = ['omit', 'same-origin', 'include']
const requestCredentials = /** @type {const} */ (['omit', 'same-origin', 'include'])

const requestCache = [
const requestCache = /** @type {const} */ ([
'default',
'no-store',
'reload',
'no-cache',
'force-cache',
'only-if-cached'
]
])

// https://fetch.spec.whatwg.org/#request-body-header-name
const requestBodyHeader = [
/**
* @see https://fetch.spec.whatwg.org/#request-body-header-name
*/
const requestBodyHeader = /** @type {const} */ ([
'content-encoding',
'content-language',
'content-location',
Expand All @@ -63,18 +68,22 @@ const requestBodyHeader = [
// removed in the Headers implementation. However, undici doesn't
// filter out headers, so we add it here.
'content-length'
]
])

// https://fetch.spec.whatwg.org/#enumdef-requestduplex
const requestDuplex = [
/**
* @see https://fetch.spec.whatwg.org/#enumdef-requestduplex
*/
const requestDuplex = /** @type {const} */ ([
'half'
]
])

// http://fetch.spec.whatwg.org/#forbidden-method
const forbiddenMethods = ['CONNECT', 'TRACE', 'TRACK']
/**
* @see http://fetch.spec.whatwg.org/#forbidden-method
*/
const forbiddenMethods = /** @type {const} */ (['CONNECT', 'TRACE', 'TRACK'])
const forbiddenMethodsSet = new Set(forbiddenMethods)

const subresource = [
const subresource = /** @type {const} */ ([
'audio',
'audioworklet',
'font',
Expand All @@ -87,7 +96,7 @@ const subresource = [
'video',
'xslt',
''
]
])
const subresourceSet = new Set(subresource)

module.exports = {
Expand Down

0 comments on commit 5be8ebf

Please sign in to comment.