Skip to content

Commit fefadbe

Browse files
authored
chore: add jsdoc to lib/web/websocket/constants.js (#3564)
1 parent 6387234 commit fefadbe

File tree

1 file changed

+67
-6
lines changed

1 file changed

+67
-6
lines changed

lib/web/websocket/constants.js

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,64 @@
11
'use strict'
22

3-
// This is a Globally Unique Identifier unique used
4-
// to validate that the endpoint accepts websocket
5-
// connections.
6-
// See https://www.rfc-editor.org/rfc/rfc6455.html#section-1.3
3+
/**
4+
* This is a Globally Unique Identifier unique used to validate that the
5+
* endpoint accepts websocket connections.
6+
* @see https://www.rfc-editor.org/rfc/rfc6455.html#section-1.3
7+
* @type {'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'}
8+
*/
79
const uid = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
810

9-
/** @type {PropertyDescriptor} */
11+
/**
12+
* @type {PropertyDescriptor}
13+
*/
1014
const staticPropertyDescriptors = {
1115
enumerable: true,
1216
writable: false,
1317
configurable: false
1418
}
1519

20+
/**
21+
* The states of the WebSocket connection.
22+
*
23+
* @readonly
24+
* @enum
25+
* @property {0} CONNECTING
26+
* @property {1} OPEN
27+
* @property {2} CLOSING
28+
* @property {3} CLOSED
29+
*/
1630
const states = {
1731
CONNECTING: 0,
1832
OPEN: 1,
1933
CLOSING: 2,
2034
CLOSED: 3
2135
}
2236

37+
/**
38+
* @readonly
39+
* @enum
40+
* @property {0} NOT_SENT
41+
* @property {1} PROCESSING
42+
* @property {2} SENT
43+
*/
2344
const sentCloseFrameState = {
2445
SENT: 1,
2546
RECEIVED: 2
2647
}
2748

49+
/**
50+
* The WebSocket opcodes.
51+
*
52+
* @readonly
53+
* @enum
54+
* @property {0x0} CONTINUATION
55+
* @property {0x1} TEXT
56+
* @property {0x2} BINARY
57+
* @property {0x8} CLOSE
58+
* @property {0x9} PING
59+
* @property {0xA} PONG
60+
* @see https://datatracker.ietf.org/doc/html/rfc6455#section-5.2
61+
*/
2862
const opcodes = {
2963
CONTINUATION: 0x0,
3064
TEXT: 0x1,
@@ -34,17 +68,44 @@ const opcodes = {
3468
PONG: 0xA
3569
}
3670

37-
const maxUnsigned16Bit = 2 ** 16 - 1 // 65535
71+
/**
72+
* The maximum value for an unsigned 16-bit integer.
73+
*
74+
* @type {65535} 2 ** 16 - 1
75+
*/
76+
const maxUnsigned16Bit = 65535
3877

78+
/**
79+
* The states of the parser.
80+
*
81+
* @readonly
82+
* @enum
83+
* @property {0} INFO
84+
* @property {2} PAYLOADLENGTH_16
85+
* @property {3} PAYLOADLENGTH_64
86+
* @property {4} READ_DATA
87+
*/
3988
const parserStates = {
4089
INFO: 0,
4190
PAYLOADLENGTH_16: 2,
4291
PAYLOADLENGTH_64: 3,
4392
READ_DATA: 4
4493
}
4594

95+
/**
96+
* An empty buffer.
97+
*
98+
* @type {Buffer}
99+
*/
46100
const emptyBuffer = Buffer.allocUnsafe(0)
47101

102+
/**
103+
* @readonly
104+
* @property {1} text
105+
* @property {2} typedArray
106+
* @property {3} arrayBuffer
107+
* @property {4} blob
108+
*/
48109
const sendHints = {
49110
text: 1,
50111
typedArray: 2,

0 commit comments

Comments
 (0)