@@ -15,6 +15,7 @@ const {
1515 Promise,
1616 PromisePrototypeThen,
1717 PromiseResolve,
18+ PromiseWithResolvers,
1819 SafeSet,
1920 String,
2021 Symbol,
@@ -56,12 +57,7 @@ const {
5657 RingBuffer,
5758} = require ( 'internal/streams/iter/ringbuffer' ) ;
5859
59- // Cached resolved promise to avoid allocating a new one on every sync fast-path.
6060const kResolvedPromise = PromiseResolve ( ) ;
61-
62- // Non-exported symbols for internal cross-class communication between
63- // BroadcastImpl and BroadcastWriter. Because these symbols are not exported,
64- // external code cannot access the internal methods/fields.
6561const kCancelWriter = Symbol ( 'cancelWriter' ) ;
6662const kWrite = Symbol ( 'write' ) ;
6763const kEnd = Symbol ( 'end' ) ;
@@ -163,8 +159,10 @@ class BroadcastImpl {
163159 const self = this ;
164160
165161 return {
162+ __proto__ : null ,
166163 [ SymbolAsyncIterator ] ( ) {
167164 return {
165+ __proto__ : null ,
168166 async next ( ) {
169167 if ( state . detached ) {
170168 // If detached due to an error, throw the error
@@ -192,10 +190,10 @@ class BroadcastImpl {
192190 return { __proto__ : null , done : true , value : undefined } ;
193191 }
194192
195- return new Promise ( ( resolve , reject ) => {
196- state . resolve = resolve ;
197- state . reject = reject ;
198- } ) ;
193+ const { promise , resolve, reject } = PromiseWithResolvers ( ) ;
194+ state . resolve = resolve ;
195+ state . reject = reject ;
196+ return promise ;
199197 } ,
200198
201199 async return ( ) {
0 commit comments