@@ -8,10 +8,13 @@ import {
88 Mode ,
99 modes ,
1010 env ,
11+ StreamEntry ,
1112} from './types.js'
1213
1314export { RedisStreamOptions , Mode }
1415
16+ type ResolvedForCaller = any
17+
1518export class RedisStream < T extends Mode = 'entry' > {
1619 //static factoryFor() { //create factory that extends options }
1720 /**
@@ -50,9 +53,9 @@ export class RedisStream<T extends Mode = 'entry'> {
5053
5154 private itr = {
5255 name : '' ,
53- prev : undefined as any ,
54- entry : undefined as any ,
55- stream : undefined as any ,
56+ prev : undefined as StreamEntry | undefined ,
57+ entry : null as IterableIterator < StreamEntry > | null ,
58+ stream : null as IterableIterator < XStreamResult > | null | undefined ,
5659 }
5760
5861 /**
@@ -147,14 +150,17 @@ export class RedisStream<T extends Mode = 'entry'> {
147150 else {
148151 this . streams . set ( itr . name , this . group ? '>' : result . value [ 0 ] . toString ( ) )
149152 if ( this . ackOnIterate ) itr . prev = result . value
150- yield [ itr . name , result . value ] as any
153+ const ret : XEntryResult = [ itr . name , result . value ]
154+ yield ret as ResolvedForCaller
151155 }
152156 }
153157 }
154158
155159 private moveCursors ( ) {
156160 if ( this . first ) {
157- this . streams . forEach ( ( v , k ) => this . streams . set ( k , '>' ) )
161+ for ( const [ stream ] of this . streams ) {
162+ this . streams . set ( stream , '>' )
163+ }
158164 this . first = false
159165 }
160166 }
@@ -176,13 +182,14 @@ export class RedisStream<T extends Mode = 'entry'> {
176182 }
177183 }
178184
179- public ack ( stream : string , ...ids : string [ ] ) : void {
185+ public ack ( stream : string , ...ids : string [ ] ) : undefined {
180186 if ( ! this . group ) {
181187 throw new Error ( 'Cannot ack entries read outside of a consumer group' )
182188 }
183189 const acks = this . pendingAcks . get ( stream ) || [ ]
184190 acks . push ( ...ids )
185191 this . pendingAcks . set ( stream , acks )
192+ return
186193 }
187194
188195 protected async return ( ) : Promise < void > {
0 commit comments