8
8
9
9
const {
10
10
codes : {
11
- ERR_INVALID_THIS ,
12
11
ERR_MISSING_OPTION ,
13
12
} ,
14
13
} = require ( 'internal/errors' ) ;
@@ -20,21 +19,12 @@ const {
20
19
21
20
const {
22
21
customInspect,
23
- isBrandCheck,
24
- kType,
25
- kState,
26
22
} = require ( 'internal/webstreams/util' ) ;
27
23
28
24
const {
29
25
validateObject,
30
26
} = require ( 'internal/validators' ) ;
31
27
32
- const isByteLengthQueuingStrategy =
33
- isBrandCheck ( 'ByteLengthQueuingStrategy' ) ;
34
-
35
- const isCountQueuingStrategy =
36
- isBrandCheck ( 'CountQueuingStrategy' ) ;
37
-
38
28
/**
39
29
* @callback QueuingStrategySize
40
30
* @param {any } chunk
@@ -68,7 +58,8 @@ const getNonWritablePropertyDescriptor = (value) => {
68
58
* @type {QueuingStrategy }
69
59
*/
70
60
class ByteLengthQueuingStrategy {
71
- [ kType ] = 'ByteLengthQueuingStrategy' ;
61
+ #state;
62
+ #byteSizeFunction = byteSizeFunction ;
72
63
73
64
/**
74
65
* @param {{
@@ -82,7 +73,7 @@ class ByteLengthQueuingStrategy {
82
73
83
74
// The highWaterMark value is not checked until the strategy
84
75
// is actually used, per the spec.
85
- this [ kState ] = {
76
+ this . #state = {
86
77
highWaterMark : + init . highWaterMark ,
87
78
} ;
88
79
}
@@ -92,22 +83,18 @@ class ByteLengthQueuingStrategy {
92
83
* @type {number }
93
84
*/
94
85
get highWaterMark ( ) {
95
- if ( ! isByteLengthQueuingStrategy ( this ) )
96
- throw new ERR_INVALID_THIS ( 'ByteLengthQueuingStrategy' ) ;
97
- return this [ kState ] . highWaterMark ;
86
+ return this . #state. highWaterMark ;
98
87
}
99
88
100
89
/**
101
90
* @type {QueuingStrategySize }
102
91
*/
103
92
get size ( ) {
104
- if ( ! isByteLengthQueuingStrategy ( this ) )
105
- throw new ERR_INVALID_THIS ( 'ByteLengthQueuingStrategy' ) ;
106
- return byteSizeFunction ;
93
+ return this . #byteSizeFunction;
107
94
}
108
95
109
96
[ kInspect ] ( depth , options ) {
110
- return customInspect ( depth , options , this [ kType ] , {
97
+ return customInspect ( depth , options , 'ByteLengthQueuingStrategy' , {
111
98
highWaterMark : this . highWaterMark ,
112
99
} ) ;
113
100
}
@@ -123,7 +110,8 @@ ObjectDefineProperties(ByteLengthQueuingStrategy.prototype, {
123
110
* @type {QueuingStrategy }
124
111
*/
125
112
class CountQueuingStrategy {
126
- [ kType ] = 'CountQueuingStrategy' ;
113
+ #state;
114
+ #countSizeFunction = countSizeFunction ;
127
115
128
116
/**
129
117
* @param {{
@@ -137,7 +125,7 @@ class CountQueuingStrategy {
137
125
138
126
// The highWaterMark value is not checked until the strategy
139
127
// is actually used, per the spec.
140
- this [ kState ] = {
128
+ this . #state = {
141
129
highWaterMark : + init . highWaterMark ,
142
130
} ;
143
131
}
@@ -147,22 +135,18 @@ class CountQueuingStrategy {
147
135
* @type {number }
148
136
*/
149
137
get highWaterMark ( ) {
150
- if ( ! isCountQueuingStrategy ( this ) )
151
- throw new ERR_INVALID_THIS ( 'CountQueuingStrategy' ) ;
152
- return this [ kState ] . highWaterMark ;
138
+ return this . #state. highWaterMark ;
153
139
}
154
140
155
141
/**
156
142
* @type {QueuingStrategySize }
157
143
*/
158
144
get size ( ) {
159
- if ( ! isCountQueuingStrategy ( this ) )
160
- throw new ERR_INVALID_THIS ( 'CountQueuingStrategy' ) ;
161
- return countSizeFunction ;
145
+ return this . #countSizeFunction;
162
146
}
163
147
164
148
[ kInspect ] ( depth , options ) {
165
- return customInspect ( depth , options , this [ kType ] , {
149
+ return customInspect ( depth , options , 'CountQueuingStrategy' , {
166
150
highWaterMark : this . highWaterMark ,
167
151
} ) ;
168
152
}
0 commit comments