diff --git a/src/client/bidiStreamProxy.ts b/src/client/bidiStreamProxy.ts index 780ac7b..4da6961 100644 --- a/src/client/bidiStreamProxy.ts +++ b/src/client/bidiStreamProxy.ts @@ -2,13 +2,13 @@ import { createClientError } from './clientError' import { combineMetadata } from './clientMetadata' import { setDeadline } from './clientDeadline' import { createContext, createResponse, ClientResponse } from './clientContext' -import Iterator from '../utils/iterator' +import { iterator } from '../utils/iterator' import { UntypedServiceImplementation, Metadata, StatusObject, ClientDuplexStream, InterceptingCall } from '@grpc/grpc-js' export type ClientDuplexStreamCall = ClientDuplexStream & { writeAll: (message: any[]) => void writeEnd: Function - readAll: () => Iterator + readAll: () => AsyncIterator readEnd: () => ClientResponse } @@ -58,7 +58,7 @@ export const bidiStreamProxy = ( ctx.status = status ctx.peer = call.getPeer() }) - return Iterator(call, 'data', { + return iterator(call, 'data', { resolutionEvents: ['status', 'end'] }) } diff --git a/src/client/serverStreamProxy.ts b/src/client/serverStreamProxy.ts index a88dce6..10404b1 100644 --- a/src/client/serverStreamProxy.ts +++ b/src/client/serverStreamProxy.ts @@ -1,12 +1,12 @@ import { createClientError } from './clientError' import { combineMetadata } from './clientMetadata' import { setDeadline } from './clientDeadline' -import Iterator from '../utils/iterator' +import { iterator } from '../utils/iterator' import { createContext, createResponse, ClientResponse } from './clientContext' import { UntypedServiceImplementation, Metadata, StatusObject, ClientReadableStream } from '@grpc/grpc-js' export type ClientReadableStreamCall = ClientReadableStream & { - readAll: () => Iterator + readAll: () => AsyncIterator readEnd: () => ClientResponse } @@ -48,7 +48,7 @@ export const serverStreamProxy = ( ctx.status = status ctx.peer = call.getPeer() }) - return Iterator(call, 'data', { + return iterator(call, 'data', { resolutionEvents: ['status', 'end'] }) } diff --git a/src/server/bidiStreamingCallProxy.ts b/src/server/bidiStreamingCallProxy.ts index b29791b..3de28cd 100644 --- a/src/server/bidiStreamingCallProxy.ts +++ b/src/server/bidiStreamingCallProxy.ts @@ -1,5 +1,5 @@ import * as grpc from '@grpc/grpc-js' -import iterator from '../utils/iterator' +import { iterator } from '../utils/iterator' import { createContext } from './serverContext' import { createServerError } from './serverError' diff --git a/src/server/clientStreamingCallProxy.ts b/src/server/clientStreamingCallProxy.ts index 43b529c..c087321 100644 --- a/src/server/clientStreamingCallProxy.ts +++ b/src/server/clientStreamingCallProxy.ts @@ -1,5 +1,5 @@ import * as grpc from '@grpc/grpc-js' -import iterator from '../utils/iterator' +import { iterator } from '../utils/iterator' import { createContext } from './serverContext' import { createServerError } from './serverError' diff --git a/src/utils/iterator.ts b/src/utils/iterator.ts index f819745..a5c55a1 100644 --- a/src/utils/iterator.ts +++ b/src/utils/iterator.ts @@ -16,7 +16,7 @@ const normalizeEmitter = (emitter: any): { addListener: Function; removeListener const toArray = (value: any): any[] => (Array.isArray(value) ? value : [value]) -export default (emitter: any, event: string | string[], options: any) => { +export const iterator = (emitter: any, event: string | string[], options: any) => { if (typeof options === 'function') { options = { filter: options } }