@@ -505,8 +505,9 @@ function* withFlushSync(source) {
505505 yield null ;
506506}
507507
508- function * applyStatefulSyncTransform ( source , transform ) {
509- const output = transform ( withFlushSync ( source ) ) ;
508+ function * applyStatefulSyncTransform ( source , transform , receiver ) {
509+ const output = FunctionPrototypeCall (
510+ transform , receiver , withFlushSync ( source ) ) ;
510511 for ( const item of output ) {
511512 if ( item === null ) continue ;
512513 const batch = [ ] ;
@@ -537,7 +538,8 @@ function* createSyncPipeline(source, transforms) {
537538 current = applyFusedStatelessSyncTransforms ( current , statelessRun ) ;
538539 statelessRun = [ ] ;
539540 }
540- current = applyStatefulSyncTransform ( current , transform . transform ) ;
541+ current = applyStatefulSyncTransform (
542+ current , transform . transform , transform ) ;
541543 } else {
542544 ArrayPrototypePush ( statelessRun , transform ) ;
543545 }
@@ -648,8 +650,10 @@ async function* withFlushAsync(source) {
648650 yield null ;
649651}
650652
651- async function * applyStatefulAsyncTransform ( source , transform , options ) {
652- const output = transform ( withFlushAsync ( source ) , options ) ;
653+ async function * applyStatefulAsyncTransform (
654+ source , transform , receiver , options ) {
655+ const output = FunctionPrototypeCall (
656+ transform , receiver , withFlushAsync ( source ) , options ) ;
653657 for await ( const item of output ) {
654658 if ( item === null ) continue ;
655659 // Fast path: item is already a Uint8Array[] batch (e.g. compression transforms)
@@ -681,8 +685,10 @@ async function* applyStatefulAsyncTransform(source, transform, options) {
681685 * skips isUint8ArrayBatch validation (transform guarantees valid output).
682686 * @yields {Uint8Array[]}
683687 */
684- async function * applyValidatedStatefulAsyncTransform ( source , transform , options ) {
685- const output = transform ( source , options ) ;
688+ async function * applyValidatedStatefulAsyncTransform (
689+ source , transform , receiver , options ) {
690+ const output = FunctionPrototypeCall (
691+ transform , receiver , source , options ) ;
686692 for await ( const batch of output ) {
687693 if ( batch . length > 0 ) {
688694 yield batch ;
@@ -750,10 +756,10 @@ async function* createAsyncPipeline(source, transforms, signal) {
750756 const opts = { __proto__ : null , signal : transformSignal } ;
751757 if ( transform [ kValidatedTransform ] ) {
752758 current = applyValidatedStatefulAsyncTransform (
753- current , transform . transform , opts ) ;
759+ current , transform . transform , transform , opts ) ;
754760 } else {
755761 current = applyStatefulAsyncTransform (
756- current , transform . transform , opts ) ;
762+ current , transform . transform , transform , opts ) ;
757763 }
758764 } else {
759765 ArrayPrototypePush ( statelessRun , transform ) ;
0 commit comments