@@ -71,23 +71,12 @@ const {
7171
7272module . exports = Transform ;
7373const {
74- ERR_ARG_RETURN_VALUE_NOT_ASYNC_ITERABLE ,
7574 ERR_METHOD_NOT_IMPLEMENTED ,
7675 ERR_MULTIPLE_CALLBACK ,
7776 ERR_TRANSFORM_ALREADY_TRANSFORMING ,
7877 ERR_TRANSFORM_WITH_LENGTH_0
7978} = require ( 'internal/errors' ) . codes ;
8079const Duplex = require ( '_stream_duplex' ) ;
81- const Readable = require ( '_stream_readable' ) ;
82- const AsyncIteratorPrototype = ObjectGetPrototypeOf (
83- ObjectGetPrototypeOf ( async function * ( ) { } ) . prototype ) ;
84-
85- const kSourceIteratorPull = Symbol ( 'kSourceIteratorPull' ) ;
86- const kSourceIteratorResolve = Symbol ( 'kSourceIteratorResolve' ) ;
87- const kSourceIteratorChunk = Symbol ( 'kSourceIteratorChunk' ) ;
88- const kSourceIteratorStream = Symbol ( 'kSourceIteratorStream' ) ;
89- const kSourceIteratorPump = Symbol ( 'kSourceIteratorPump' ) ;
90- const kSourceIteratorGrabResolve = Symbol ( 'kSourceIteratorGrabResolve' ) ;
9180
9281ObjectSetPrototypeOf ( Transform . prototype , Duplex . prototype ) ;
9382ObjectSetPrototypeOf ( Transform , Duplex ) ;
@@ -235,10 +224,15 @@ function done(stream, er, data) {
235224
236225const from = require ( 'internal/streams/from' ) ;
237226
238- Transform . by = function by ( asyncGeneratorFn , opts ) {
227+ Transform . by = function by ( transform , opts ) {
239228 let _resolve ;
240229 let _promise = new Promise ( ( resolve ) => _resolve = resolve ) ;
241- return from ( Duplex , asyncGeneratorFn ( async function * ( ) {
230+
231+ if ( typeof transform !== 'function' ) {
232+ throw new ERR_INVALID_ARG_TYPE ( 'transform' , [ 'function' ] , iterable ) ;
233+ }
234+
235+ return from ( Duplex , transform ( async function * ( ) {
242236 while ( true ) {
243237 const { chunk, done, cb } = await _promise ;
244238 if ( done ) return cb ( ) ;
0 commit comments