Skip to content

Commit

Permalink
chore: adjust iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
chakhsu committed Jan 8, 2024
1 parent d9b109a commit 6bc408d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/client/bidiStreamProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Request, Response> & {
writeAll: (message: any[]) => void
writeEnd: Function
readAll: () => Iterator<any, any, any>
readAll: () => AsyncIterator<any, any, any>
readEnd: () => ClientResponse
}

Expand Down Expand Up @@ -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']
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/client/serverStreamProxy.ts
Original file line number Diff line number Diff line change
@@ -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<Request> & {
readAll: () => Iterator<any, any, any>
readAll: () => AsyncIterator<any, any, any>
readEnd: () => ClientResponse
}

Expand Down Expand Up @@ -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']
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/bidiStreamingCallProxy.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion src/server/clientStreamingCallProxy.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion src/utils/iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down

0 comments on commit 6bc408d

Please sign in to comment.