88
99const {
1010 codes : {
11- ERR_INVALID_THIS ,
1211 ERR_MISSING_OPTION ,
1312 } ,
1413} = require ( 'internal/errors' ) ;
@@ -20,21 +19,12 @@ const {
2019
2120const {
2221 customInspect,
23- isBrandCheck,
24- kType,
25- kState,
2622} = require ( 'internal/webstreams/util' ) ;
2723
2824const {
2925 validateObject,
3026} = require ( 'internal/validators' ) ;
3127
32- const isByteLengthQueuingStrategy =
33- isBrandCheck ( 'ByteLengthQueuingStrategy' ) ;
34-
35- const isCountQueuingStrategy =
36- isBrandCheck ( 'CountQueuingStrategy' ) ;
37-
3828/**
3929 * @callback QueuingStrategySize
4030 * @param {any } chunk
@@ -68,7 +58,8 @@ const getNonWritablePropertyDescriptor = (value) => {
6858 * @type {QueuingStrategy }
6959 */
7060class ByteLengthQueuingStrategy {
71- [ kType ] = 'ByteLengthQueuingStrategy' ;
61+ #state;
62+ #byteSizeFunction = byteSizeFunction ;
7263
7364 /**
7465 * @param {{
@@ -82,7 +73,7 @@ class ByteLengthQueuingStrategy {
8273
8374 // The highWaterMark value is not checked until the strategy
8475 // is actually used, per the spec.
85- this [ kState ] = {
76+ this . #state = {
8677 highWaterMark : + init . highWaterMark ,
8778 } ;
8879 }
@@ -92,22 +83,18 @@ class ByteLengthQueuingStrategy {
9283 * @type {number }
9384 */
9485 get highWaterMark ( ) {
95- if ( ! isByteLengthQueuingStrategy ( this ) )
96- throw new ERR_INVALID_THIS ( 'ByteLengthQueuingStrategy' ) ;
97- return this [ kState ] . highWaterMark ;
86+ return this . #state. highWaterMark ;
9887 }
9988
10089 /**
10190 * @type {QueuingStrategySize }
10291 */
10392 get size ( ) {
104- if ( ! isByteLengthQueuingStrategy ( this ) )
105- throw new ERR_INVALID_THIS ( 'ByteLengthQueuingStrategy' ) ;
106- return byteSizeFunction ;
93+ return this . #byteSizeFunction;
10794 }
10895
10996 [ kInspect ] ( depth , options ) {
110- return customInspect ( depth , options , this [ kType ] , {
97+ return customInspect ( depth , options , 'ByteLengthQueuingStrategy' , {
11198 highWaterMark : this . highWaterMark ,
11299 } ) ;
113100 }
@@ -123,7 +110,8 @@ ObjectDefineProperties(ByteLengthQueuingStrategy.prototype, {
123110 * @type {QueuingStrategy }
124111 */
125112class CountQueuingStrategy {
126- [ kType ] = 'CountQueuingStrategy' ;
113+ #state;
114+ #countSizeFunction = countSizeFunction ;
127115
128116 /**
129117 * @param {{
@@ -137,7 +125,7 @@ class CountQueuingStrategy {
137125
138126 // The highWaterMark value is not checked until the strategy
139127 // is actually used, per the spec.
140- this [ kState ] = {
128+ this . #state = {
141129 highWaterMark : + init . highWaterMark ,
142130 } ;
143131 }
@@ -147,22 +135,18 @@ class CountQueuingStrategy {
147135 * @type {number }
148136 */
149137 get highWaterMark ( ) {
150- if ( ! isCountQueuingStrategy ( this ) )
151- throw new ERR_INVALID_THIS ( 'CountQueuingStrategy' ) ;
152- return this [ kState ] . highWaterMark ;
138+ return this . #state. highWaterMark ;
153139 }
154140
155141 /**
156142 * @type {QueuingStrategySize }
157143 */
158144 get size ( ) {
159- if ( ! isCountQueuingStrategy ( this ) )
160- throw new ERR_INVALID_THIS ( 'CountQueuingStrategy' ) ;
161- return countSizeFunction ;
145+ return this . #countSizeFunction;
162146 }
163147
164148 [ kInspect ] ( depth , options ) {
165- return customInspect ( depth , options , this [ kType ] , {
149+ return customInspect ( depth , options , 'CountQueuingStrategy' , {
166150 highWaterMark : this . highWaterMark ,
167151 } ) ;
168152 }
0 commit comments