Skip to content

Commit 5be8ebf

Browse files
jsdoc: add jsdoc to lib/web/fetch/constants.js (#3597) (#3710)
(cherry picked from commit 3d0ce67) Co-authored-by: Aras Abbasi <[email protected]>
1 parent 24b9403 commit 5be8ebf

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

lib/web/fetch/constants.js

+35-26
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
'use strict'
22

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

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

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

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

23-
// https://w3c.github.io/webappsec-referrer-policy/#referrer-policies
24-
const referrerPolicy = [
24+
/**
25+
* @see https://w3c.github.io/webappsec-referrer-policy/#referrer-policies
26+
*/
27+
const referrerPolicy = /** @type {const} */ ([
2528
'',
2629
'no-referrer',
2730
'no-referrer-when-downgrade',
@@ -31,29 +34,31 @@ const referrerPolicy = [
3134
'origin-when-cross-origin',
3235
'strict-origin-when-cross-origin',
3336
'unsafe-url'
34-
]
37+
])
3538
const referrerPolicySet = new Set(referrerPolicy)
3639

37-
const requestRedirect = ['follow', 'manual', 'error']
40+
const requestRedirect = /** @type {const} */ (['follow', 'manual', 'error'])
3841

39-
const safeMethods = ['GET', 'HEAD', 'OPTIONS', 'TRACE']
42+
const safeMethods = /** @type {const} */ (['GET', 'HEAD', 'OPTIONS', 'TRACE'])
4043
const safeMethodsSet = new Set(safeMethods)
4144

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

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

46-
const requestCache = [
49+
const requestCache = /** @type {const} */ ([
4750
'default',
4851
'no-store',
4952
'reload',
5053
'no-cache',
5154
'force-cache',
5255
'only-if-cached'
53-
]
56+
])
5457

55-
// https://fetch.spec.whatwg.org/#request-body-header-name
56-
const requestBodyHeader = [
58+
/**
59+
* @see https://fetch.spec.whatwg.org/#request-body-header-name
60+
*/
61+
const requestBodyHeader = /** @type {const} */ ([
5762
'content-encoding',
5863
'content-language',
5964
'content-location',
@@ -63,18 +68,22 @@ const requestBodyHeader = [
6368
// removed in the Headers implementation. However, undici doesn't
6469
// filter out headers, so we add it here.
6570
'content-length'
66-
]
71+
])
6772

68-
// https://fetch.spec.whatwg.org/#enumdef-requestduplex
69-
const requestDuplex = [
73+
/**
74+
* @see https://fetch.spec.whatwg.org/#enumdef-requestduplex
75+
*/
76+
const requestDuplex = /** @type {const} */ ([
7077
'half'
71-
]
78+
])
7279

73-
// http://fetch.spec.whatwg.org/#forbidden-method
74-
const forbiddenMethods = ['CONNECT', 'TRACE', 'TRACK']
80+
/**
81+
* @see http://fetch.spec.whatwg.org/#forbidden-method
82+
*/
83+
const forbiddenMethods = /** @type {const} */ (['CONNECT', 'TRACE', 'TRACK'])
7584
const forbiddenMethodsSet = new Set(forbiddenMethods)
7685

77-
const subresource = [
86+
const subresource = /** @type {const} */ ([
7887
'audio',
7988
'audioworklet',
8089
'font',
@@ -87,7 +96,7 @@ const subresource = [
8796
'video',
8897
'xslt',
8998
''
90-
]
99+
])
91100
const subresourceSet = new Set(subresource)
92101

93102
module.exports = {

0 commit comments

Comments
 (0)