Skip to content

Commit 16434bc

Browse files
committed
feat: remove mode generic
1 parent 2ca6a5a commit 16434bc

File tree

8 files changed

+104
-235
lines changed

8 files changed

+104
-235
lines changed

docs/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ Requires Redis 5 or greater.
88
## Getting Started
99

1010
```javascript
11-
import streamEntries from 'redis-x-stream'
11+
import stream from 'redis-x-stream'
1212

13-
for await (const [stream, [id, keyvals]] of streamEntries('myStream')) {
13+
for await (const [streamName, [id, keyvals]] of stream('myStream')) {
1414
//process an entry
1515
}
1616
```
1717
## Usage
1818

1919
See [API Docs](docs/classes/redisstream.md#constructor)
20-
21-
## Not yet implemented
22-
- batch mode
23-
- stream mode

docs/classes/redisstream.md

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
[redis-x-stream](../README.md) / [Exports](../modules.md) / RedisStream
22

3-
# Class: RedisStream<T\>
4-
5-
## Type parameters
6-
7-
| Name | Type |
8-
| :------ | :------ |
9-
| `T` | extends [`Mode`](../modules.md#mode) = ``"entry"`` |
3+
# Class: RedisStream
104

115
## Table of contents
126

@@ -26,7 +20,6 @@
2620
- [done](RedisStream.md#done)
2721
- [first](RedisStream.md#first)
2822
- [group](RedisStream.md#group)
29-
- [mode](RedisStream.md#mode)
3023
- [noack](RedisStream.md#noack)
3124
- [pendingAcks](RedisStream.md#pendingacks)
3225
- [streams](RedisStream.md#streams)
@@ -42,24 +35,18 @@
4235

4336
### constructor
4437

45-
**new RedisStream**<`T`\>(`options`, ...`streams`)
46-
47-
#### Type parameters
48-
49-
| Name | Type |
50-
| :------ | :------ |
51-
| `T` | extends [`Mode`](../modules.md#mode) = ``"entry"`` |
38+
**new RedisStream**(`options`, ...`streams`)
5239

5340
#### Parameters
5441

5542
| Name | Type |
5643
| :------ | :------ |
57-
| `options` | `string` \| [`RedisStreamOptions`](../interfaces/RedisStreamOptions.md)<`T`\> |
44+
| `options` | `string` \| [`RedisStreamOptions`](../interfaces/RedisStreamOptions.md) |
5845
| `...streams` | `string`[] |
5946

6047
#### Defined in
6148

62-
[stream.ts:63](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L63)
49+
[stream.ts:63](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L63)
6350

6451
## Properties
6552

@@ -69,7 +56,7 @@
6956

7057
#### Defined in
7158

72-
[stream.ts:35](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L35)
59+
[stream.ts:35](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L35)
7360

7461
___
7562

@@ -79,7 +66,7 @@ ___
7966

8067
#### Defined in
8168

82-
[stream.ts:31](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L31)
69+
[stream.ts:31](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L31)
8370

8471
___
8572

@@ -89,17 +76,21 @@ ___
8976

9077
#### Defined in
9178

92-
[stream.ts:32](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L32)
79+
[stream.ts:32](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L32)
9380

9481
___
9582

9683
### client
9784

9885
`Readonly` **client**: `Redis`
9986

87+
'entry' mode will dispense each entry of each stream
88+
'stream' mode will dispense each stream containing entries
89+
'batch' mode will dispense all streams with all entries
90+
10091
#### Defined in
10192

102-
[stream.ts:23](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L23)
93+
[stream.ts:23](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L23)
10394

10495
___
10596

@@ -109,7 +100,7 @@ ___
109100

110101
#### Defined in
111102

112-
[stream.ts:25](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L25)
103+
[stream.ts:25](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L25)
113104

114105
___
115106

@@ -119,7 +110,7 @@ ___
119110

120111
#### Defined in
121112

122-
[stream.ts:29](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L29)
113+
[stream.ts:29](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L29)
123114

124115
___
125116

@@ -129,7 +120,7 @@ ___
129120

130121
#### Defined in
131122

132-
[stream.ts:36](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L36)
123+
[stream.ts:36](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L36)
133124

134125
___
135126

@@ -141,7 +132,7 @@ Flag for iterable state
141132

142133
#### Defined in
143134

144-
[stream.ts:48](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L48)
135+
[stream.ts:48](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L48)
145136

146137
___
147138

@@ -151,7 +142,7 @@ ___
151142

152143
#### Defined in
153144

154-
[stream.ts:49](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L49)
145+
[stream.ts:49](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L49)
155146

156147
___
157148

@@ -161,21 +152,7 @@ ___
161152

162153
#### Defined in
163154

164-
[stream.ts:24](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L24)
165-
166-
___
167-
168-
### mode
169-
170-
`Readonly` **mode**: [`Mode`](../modules.md#mode) = `'entry'`
171-
172-
'entry' mode will dispense each entry of each stream
173-
'stream' mode will dispense each stream containing entries
174-
'batch' mode will dispense all streams with all entries
175-
176-
#### Defined in
177-
178-
[stream.ts:22](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L22)
155+
[stream.ts:24](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L24)
179156

180157
___
181158

@@ -185,7 +162,7 @@ ___
185162

186163
#### Defined in
187164

188-
[stream.ts:30](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L30)
165+
[stream.ts:30](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L30)
189166

190167
___
191168

@@ -199,7 +176,7 @@ Acks waiting to be sent on either:
199176

200177
#### Defined in
201178

202-
[stream.ts:44](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L44)
179+
[stream.ts:44](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L44)
203180

204181
___
205182

@@ -209,27 +186,27 @@ ___
209186

210187
#### Defined in
211188

212-
[stream.ts:28](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L28)
189+
[stream.ts:28](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L28)
213190

214191
## Methods
215192

216193
### [asyncIterator]
217194

218-
**[asyncIterator]**(): `AsyncIterator`<`T` extends ``"entry"`` ? `XEntryResult` : `T` extends ``"batch"`` ? `XStreamResult`[] : `XStreamResult`, `any`, `undefined`\>
195+
**[asyncIterator]**(): `AsyncIterator`<`XEntryResult`, `any`, `undefined`\>
219196

220197
#### Returns
221198

222-
`AsyncIterator`<`T` extends ``"entry"`` ? `XEntryResult` : `T` extends ``"batch"`` ? `XStreamResult`[] : `XStreamResult`, `any`, `undefined`\>
199+
`AsyncIterator`<`XEntryResult`, `any`, `undefined`\>
223200

224201
#### Defined in
225202

226-
[stream.ts:124](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L124)
203+
[stream.ts:128](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L128)
227204

228205
___
229206

230207
### ack
231208

232-
**ack**(`stream`, ...`ids`): `void`
209+
**ack**(`stream`, ...`ids`): `undefined`
233210

234211
#### Parameters
235212

@@ -240,11 +217,11 @@ ___
240217

241218
#### Returns
242219

243-
`void`
220+
`undefined`
244221

245222
#### Defined in
246223

247-
[stream.ts:179](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L179)
224+
[stream.ts:185](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L185)
248225

249226
___
250227

@@ -258,7 +235,7 @@ ___
258235

259236
#### Defined in
260237

261-
[stream.ts:168](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L168)
238+
[stream.ts:174](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L174)
262239

263240
___
264241

@@ -272,4 +249,4 @@ ___
272249

273250
#### Defined in
274251

275-
[stream.ts:188](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L188)
252+
[stream.ts:195](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L195)

docs/interfaces/redisstreamoptions.md

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
[redis-x-stream](../README.md) / [Exports](../modules.md) / RedisStreamOptions
22

3-
# Interface: RedisStreamOptions<T\>
4-
5-
## Type parameters
6-
7-
| Name | Type |
8-
| :------ | :------ |
9-
| `T` | extends [`Mode`](../modules.md#mode) |
3+
# Interface: RedisStreamOptions
104

115
## Table of contents
126

@@ -20,7 +14,6 @@
2014
- [deleteOnAck](RedisStreamOptions.md#deleteonack)
2115
- [flushPendingAckInterval](RedisStreamOptions.md#flushpendingackinterval)
2216
- [group](RedisStreamOptions.md#group)
23-
- [mode](RedisStreamOptions.md#mode)
2417
- [noack](RedisStreamOptions.md#noack)
2518
- [redis](RedisStreamOptions.md#redis)
2619
- [streams](RedisStreamOptions.md#streams)
@@ -40,7 +33,7 @@ false
4033

4134
#### Defined in
4235

43-
[types.ts:98](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L98)
36+
[types.ts:71](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L71)
4437

4538
___
4639

@@ -53,7 +46,7 @@ while waiting for new entries on any stream, passed to xread or xreadgroup
5346

5447
#### Defined in
5548

56-
[types.ts:92](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L92)
49+
[types.ts:65](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L65)
5750

5851
___
5952

@@ -66,7 +59,7 @@ This applies to entry id and kv results
6659

6760
#### Defined in
6861

69-
[types.ts:81](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L81)
62+
[types.ts:54](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L54)
7063

7164
___
7265

@@ -79,7 +72,7 @@ Note: if only consumer is provided, a group is created automatically
7972

8073
#### Defined in
8174

82-
[types.ts:71](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L71)
75+
[types.ts:44](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L44)
8376

8477
___
8578

@@ -96,7 +89,7 @@ eg. the "highWaterMark"
9689

9790
#### Defined in
9891

99-
[types.ts:87](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L87)
92+
[types.ts:60](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L60)
10093

10194
___
10295

@@ -113,7 +106,7 @@ false
113106

114107
#### Defined in
115108

116-
[types.ts:104](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L104)
109+
[types.ts:77](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L77)
117110

118111
___
119112

@@ -128,7 +121,7 @@ TODO: not yet implemented
128121

129122
#### Defined in
130123

131-
[types.ts:116](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L116)
124+
[types.ts:89](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L89)
132125

133126
___
134127

@@ -141,27 +134,7 @@ Note: if only a group is provided a consumer is created automatically
141134

142135
#### Defined in
143136

144-
[types.ts:66](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L66)
145-
146-
___
147-
148-
### mode
149-
150-
`Optional` **mode**: `T`
151-
152-
`'entry'` mode is default and will iterate over each stream entry in each stream in the result set
153-
154-
`'stream'` mode will iterate over each XREAD[GROUP] stream result
155-
156-
`'batch'` mode will iterate over each XREAD[GROUP] call result
157-
158-
**`Default`**
159-
160-
`'entry'`
161-
162-
#### Defined in
163-
164-
[types.ts:57](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L57)
137+
[types.ts:39](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L39)
165138

166139
___
167140

@@ -177,7 +150,7 @@ false
177150

178151
#### Defined in
179152

180-
[types.ts:109](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L109)
153+
[types.ts:82](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L82)
181154

182155
___
183156

@@ -190,7 +163,7 @@ NOTE: by default this connection becomes a "reader" when block > 0
190163

191164
#### Defined in
192165

193-
[types.ts:76](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L76)
166+
[types.ts:49](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L49)
194167

195168
___
196169

@@ -202,4 +175,4 @@ Redis stream keys to be read. If a Record is provided each value is the starting
202175

203176
#### Defined in
204177

205-
[types.ts:61](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L61)
178+
[types.ts:34](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L34)

0 commit comments

Comments
 (0)