1- import { Readable , Transform } from 'stream' ;
1+ import { Readable } from 'stream' ;
22
33import { type BSONSerializeOptions , type Document , Long , pluckBSONSerializeOptions } from '../bson' ;
44import { type OnDemandDocumentDeserializeOptions } from '../cmap/wire_protocol/on_demand/document' ;
@@ -58,12 +58,6 @@ export const CURSOR_FLAGS = [
5858 'partial'
5959] as const ;
6060
61- /** @public */
62- export interface CursorStreamOptions {
63- /** A transformation method applied to each document emitted by the stream */
64- transform ?( this : void , doc : Document ) : Document ;
65- }
66-
6761/** @public */
6862export type CursorFlag = ( typeof CURSOR_FLAGS ) [ number ] ;
6963
@@ -519,7 +513,7 @@ export abstract class AbstractCursor<
519513 }
520514 }
521515
522- stream ( options ?: CursorStreamOptions ) : Readable & AsyncIterable < TSchema > {
516+ stream ( ) : Readable & AsyncIterable < TSchema > {
523517 const readable = new ReadableCursorStream ( this ) ;
524518 const abortListener = addAbortListener ( this . signal , function ( ) {
525519 readable . destroy ( this . reason ) ;
@@ -528,31 +522,6 @@ export abstract class AbstractCursor<
528522 abortListener ?. [ kDispose ] ( ) ;
529523 } ) ;
530524
531- if ( options ?. transform ) {
532- const transform = options . transform ;
533-
534- const transformedStream = readable . pipe (
535- new Transform ( {
536- objectMode : true ,
537- highWaterMark : 1 ,
538- transform ( chunk , _ , callback ) {
539- try {
540- const transformed = transform ( chunk ) ;
541- callback ( undefined , transformed ) ;
542- } catch ( err ) {
543- callback ( err ) ;
544- }
545- }
546- } )
547- ) ;
548-
549- // Bubble errors to transformed stream, because otherwise no way
550- // to handle this error.
551- readable . on ( 'error' , err => transformedStream . emit ( 'error' , err ) ) ;
552-
553- return transformedStream ;
554- }
555-
556525 return readable ;
557526 }
558527
0 commit comments