@@ -4,8 +4,8 @@ import { pushScanArguments } from './SCAN';
44import { parseGeoSearchArguments , parseGeoSearchOptions } from './GEOSEARCH' ;
55import GEOSEARCH_WITH , { GEO_REPLY_WITH } from './GEOSEARCH_WITH' ;
66import {
7- transformBooleanReply as transformBooleanReplyTransformer ,
8- transformBooleanArrayReply as transformBooleanArrayReplyTransformer ,
7+ transformBooleanReply ,
8+ transformBooleanArrayReply ,
99 transformDoubleReply ,
1010 transformNullableDoubleReply ,
1111 transformDoubleArgument ,
@@ -24,17 +24,16 @@ import {
2424 transformCommandReply ,
2525 CommandFlags ,
2626 CommandCategories ,
27- parseSlotRangesArguments
27+ parseSlotRangesArguments ,
28+ Stringable ,
29+ StreamMessageRawReply ,
30+ StreamsMessagesRawReply2
2831} from './generic-transformers' ;
32+ import { ArrayReply , BlobStringReply , DoubleReply , NullReply , NumberReply , TuplesReply , UnwrapReply } from '../RESP/types' ;
2933
30- const transformBooleanReply = transformBooleanReplyTransformer [ 2 ] ;
31- const transformBooleanArrayReply = transformBooleanArrayReplyTransformer [ 2 ] ;
32- const transformNumberInfinityReply = transformDoubleReply [ 2 ] ;
33- const transformNumberInfinityNullReply = transformNullableDoubleReply [ 2 ] ;
3434const transformNumberInfinityArgument = transformDoubleArgument ;
3535const transformStringNumberInfinityArgument = transformStringDoubleArgument ;
3636const transformStreamsMessagesReply = transformStreamsMessagesReplyResp2 ;
37- const transformSortedSetWithScoresReply = transformSortedSetReply [ 2 ] ;
3837const GeoReplyWith = GEO_REPLY_WITH ;
3938const transformGeoMembersWithReply = GEOSEARCH_WITH . transformReply ;
4039
@@ -107,32 +106,35 @@ function pushSlotRangesArguments(
107106
108107describe ( 'Generic Transformers' , ( ) => {
109108 describe ( 'transformBooleanReply' , ( ) => {
109+ assert . equal ( transformBooleanReply [ 3 ] , undefined ) ;
110110 it ( '0' , ( ) => {
111111 assert . equal (
112- transformBooleanReply ( 0 ) ,
112+ transformBooleanReply [ 2 ] ( 0 as unknown as NumberReply < 0 | 1 > ) ,
113113 false
114114 ) ;
115115 } ) ;
116116
117117 it ( '1' , ( ) => {
118118 assert . equal (
119- transformBooleanReply ( 1 ) ,
119+ transformBooleanReply [ 2 ] ( 1 as unknown as NumberReply < 0 | 1 > ) ,
120120 true
121121 ) ;
122122 } ) ;
123+
123124 } ) ;
124125
125126 describe ( 'transformBooleanArrayReply' , ( ) => {
127+ assert . equal ( transformBooleanArrayReply [ 3 ] , undefined ) ;
126128 it ( 'empty array' , ( ) => {
127129 assert . deepEqual (
128- transformBooleanArrayReply ( [ ] ) ,
130+ transformBooleanArrayReply [ 2 ] ( [ ] as unknown as ArrayReply < NumberReply < 0 | 1 > > ) ,
129131 [ ]
130132 ) ;
131133 } ) ;
132134
133135 it ( '0, 1' , ( ) => {
134136 assert . deepEqual (
135- transformBooleanArrayReply ( [ 0 , 1 ] ) ,
137+ transformBooleanArrayReply [ 2 ] ( [ 0 , 1 ] as unknown as ArrayReply < NumberReply < 0 | 1 > > ) ,
136138 [ false , true ]
137139 ) ;
138140 } ) ;
@@ -141,14 +143,14 @@ describe('Generic Transformers', () => {
141143 describe ( 'pushScanArguments' , ( ) => {
142144 it ( 'cusror only' , ( ) => {
143145 assert . deepEqual (
144- pushScanArguments ( [ ] , 0 ) ,
146+ pushScanArguments ( [ ] , '0' ) ,
145147 [ '0' ]
146148 ) ;
147149 } ) ;
148150
149151 it ( 'with MATCH' , ( ) => {
150152 assert . deepEqual (
151- pushScanArguments ( [ ] , 0 , {
153+ pushScanArguments ( [ ] , '0' , {
152154 MATCH : 'pattern'
153155 } ) ,
154156 [ '0' , 'MATCH' , 'pattern' ]
@@ -157,7 +159,7 @@ describe('Generic Transformers', () => {
157159
158160 it ( 'with COUNT' , ( ) => {
159161 assert . deepEqual (
160- pushScanArguments ( [ ] , 0 , {
162+ pushScanArguments ( [ ] , '0' , {
161163 COUNT : 1
162164 } ) ,
163165 [ '0' , 'COUNT' , '1' ]
@@ -166,7 +168,7 @@ describe('Generic Transformers', () => {
166168
167169 it ( 'with MATCH & COUNT' , ( ) => {
168170 assert . deepEqual (
169- pushScanArguments ( [ ] , 0 , {
171+ pushScanArguments ( [ ] , '0' , {
170172 MATCH : 'pattern' ,
171173 COUNT : 1
172174 } ) ,
@@ -175,40 +177,42 @@ describe('Generic Transformers', () => {
175177 } ) ;
176178 } ) ;
177179
178- describe ( 'transformNumberInfinityReply' , ( ) => {
180+ describe ( 'transformDoubleReply' , ( ) => {
181+ assert . equal ( transformDoubleReply [ 3 ] , undefined ) ;
179182 it ( '0.5' , ( ) => {
180183 assert . equal (
181- transformNumberInfinityReply ( '0.5' ) ,
184+ transformDoubleReply [ 2 ] ( '0.5' as unknown as BlobStringReply < string > ) ,
182185 0.5
183186 ) ;
184187 } ) ;
185188
186189 it ( '+inf' , ( ) => {
187190 assert . equal (
188- transformNumberInfinityReply ( '+inf' ) ,
191+ transformDoubleReply [ 2 ] ( '+inf' as unknown as BlobStringReply < string > ) ,
189192 Infinity
190193 ) ;
191194 } ) ;
192195
193196 it ( '-inf' , ( ) => {
194197 assert . equal (
195- transformNumberInfinityReply ( '-inf' ) ,
198+ transformDoubleReply [ 2 ] ( '-inf' as unknown as BlobStringReply < string > ) ,
196199 - Infinity
197200 ) ;
198201 } ) ;
199202 } ) ;
200203
201204 describe ( 'transformNumberInfinityNullReply' , ( ) => {
205+ assert . equal ( transformNullableDoubleReply [ 3 ] , undefined ) ;
202206 it ( 'null' , ( ) => {
203207 assert . equal (
204- transformNumberInfinityNullReply ( null ) ,
208+ transformNullableDoubleReply [ 2 ] ( null as unknown as NullReply ) ,
205209 null
206210 ) ;
207211 } ) ;
208212
209213 it ( '1' , ( ) => {
210214 assert . equal (
211- transformNumberInfinityNullReply ( '1' ) ,
215+ transformNullableDoubleReply [ 2 ] ( '1' as unknown as BlobStringReply < string > ) ,
212216 1
213217 ) ;
214218 } ) ;
@@ -255,7 +259,7 @@ describe('Generic Transformers', () => {
255259
256260 it ( 'transformTuplesReply' , ( ) => {
257261 assert . deepEqual (
258- transformTuplesReply ( [ 'key1' , 'value1' , 'key2' , 'value2' ] ) ,
262+ transformTuplesReply ( [ 'key1' , 'value1' , 'key2' , 'value2' ] as unknown as ArrayReply < Stringable > ) ,
259263 Object . create ( { } , {
260264 key1 : {
261265 value : 'value1' ,
@@ -273,7 +277,7 @@ describe('Generic Transformers', () => {
273277
274278 it ( 'transformStreamMessagesReply' , ( ) => {
275279 assert . deepEqual (
276- transformStreamMessagesReply ( [ [ '0-0' , [ '0key' , '0value' ] ] , [ '1-0' , [ '1key' , '1value' ] ] ] ) ,
280+ transformStreamMessagesReply ( [ [ '0-0' , [ '0key' , '0value' ] ] , [ '1-0' , [ '1key' , '1value' ] ] ] as unknown as ArrayReply < StreamMessageRawReply > ) ,
277281 [ {
278282 id : '0-0' ,
279283 message : Object . create ( { } , {
@@ -306,7 +310,7 @@ describe('Generic Transformers', () => {
306310
307311 it ( 'with messages' , ( ) => {
308312 assert . deepEqual (
309- transformStreamsMessagesReply ( [ [ 'stream1' , [ [ '0-1' , [ '11key' , '11value' ] ] , [ '1-1' , [ '12key' , '12value' ] ] ] ] , [ 'stream2' , [ [ '0-2' , [ '2key1' , '2value1' , '2key2' , '2value2' ] ] ] ] ] ) ,
313+ transformStreamsMessagesReply ( [ [ 'stream1' , [ [ '0-1' , [ '11key' , '11value' ] ] , [ '1-1' , [ '12key' , '12value' ] ] ] ] , [ 'stream2' , [ [ '0-2' , [ '2key1' , '2value1' , '2key2' , '2value2' ] ] ] ] ] as unknown as UnwrapReply < StreamsMessagesRawReply2 > ) ,
310314 [ {
311315 name : 'stream1' ,
312316 messages : [ {
@@ -350,9 +354,22 @@ describe('Generic Transformers', () => {
350354 } ) ;
351355 } ) ;
352356
353- it ( 'transformSortedSetWithScoresReply' , ( ) => {
357+ it ( 'transformSortedSetReply' , ( ) => {
358+ assert . deepEqual (
359+ transformSortedSetReply [ 2 ] ( [ 'member1' , '0.5' , 'member2' , '+inf' , 'member3' , '-inf' ] as unknown as ArrayReply < BlobStringReply > ) ,
360+ [ {
361+ value : 'member1' ,
362+ score : 0.5
363+ } , {
364+ value : 'member2' ,
365+ score : Infinity
366+ } , {
367+ value : 'member3' ,
368+ score : - Infinity
369+ } ]
370+ ) ;
354371 assert . deepEqual (
355- transformSortedSetWithScoresReply ( [ 'member1' , ' 0.5' , 'member2' , '+inf' , 'member3' , '-inf' ] ) ,
372+ transformSortedSetReply [ 3 ] ( [ [ 'member1' , 0.5 ] , [ 'member2' , Infinity ] , [ 'member3' , - Infinity ] ] as unknown as ArrayReply < TuplesReply < [ BlobStringReply , DoubleReply ] > > ) ,
356373 [ {
357374 value : 'member1' ,
358375 score : 0.5
@@ -455,18 +472,18 @@ describe('Generic Transformers', () => {
455472 [
456473 '1' ,
457474 '2'
458- ] ,
475+ ] as unknown as TuplesReply < [ BlobStringReply , ... Array < any > ] > ,
459476 [
460477 '3' ,
461478 '4'
462- ]
479+ ] as unknown as TuplesReply < [ BlobStringReply , ... Array < any > ] >
463480 ] , [ GeoReplyWith . DISTANCE ] ) ,
464481 [ {
465482 member : '1' ,
466- distance : '2'
483+ distance : 2
467484 } , {
468485 member : '3' ,
469- distance : '4'
486+ distance : 4
470487 } ]
471488 ) ;
472489 } ) ;
@@ -477,11 +494,11 @@ describe('Generic Transformers', () => {
477494 [
478495 '1' ,
479496 2
480- ] ,
497+ ] as unknown as TuplesReply < [ BlobStringReply , ... Array < any > ] > ,
481498 [
482499 '3' ,
483500 4
484- ]
501+ ] as unknown as TuplesReply < [ BlobStringReply , ... Array < any > ] >
485502 ] , [ GeoReplyWith . HASH ] ) ,
486503 [ {
487504 member : '1' ,
@@ -502,26 +519,26 @@ describe('Generic Transformers', () => {
502519 '2' ,
503520 '3'
504521 ]
505- ] ,
522+ ] as unknown as TuplesReply < [ BlobStringReply , ... Array < any > ] > ,
506523 [
507524 '4' ,
508525 [
509526 '5' ,
510527 '6'
511528 ]
512- ]
529+ ] as unknown as TuplesReply < [ BlobStringReply , ... Array < any > ] >
513530 ] , [ GeoReplyWith . COORDINATES ] ) ,
514531 [ {
515532 member : '1' ,
516533 coordinates : {
517- longitude : '2' ,
518- latitude : '3'
534+ longitude : 2 ,
535+ latitude : 3
519536 }
520537 } , {
521538 member : '4' ,
522539 coordinates : {
523- longitude : '5' ,
524- latitude : '6'
540+ longitude : 5 ,
541+ latitude : 6
525542 }
526543 } ]
527544 ) ;
@@ -538,7 +555,7 @@ describe('Generic Transformers', () => {
538555 '4' ,
539556 '5'
540557 ]
541- ] ,
558+ ] as unknown as TuplesReply < [ BlobStringReply , ... Array < any > ] > ,
542559 [
543560 '6' ,
544561 '7' ,
@@ -547,23 +564,23 @@ describe('Generic Transformers', () => {
547564 '9' ,
548565 '10'
549566 ]
550- ]
567+ ] as unknown as TuplesReply < [ BlobStringReply , ... Array < any > ] >
551568 ] , [ GeoReplyWith . DISTANCE , GeoReplyWith . HASH , GeoReplyWith . COORDINATES ] ) ,
552569 [ {
553570 member : '1' ,
554- distance : '2' ,
571+ distance : 2 ,
555572 hash : 3 ,
556573 coordinates : {
557- longitude : '4' ,
558- latitude : '5'
574+ longitude : 4 ,
575+ latitude : 5
559576 }
560577 } , {
561578 member : '6' ,
562- distance : '7' ,
579+ distance : 7 ,
563580 hash : 8 ,
564581 coordinates : {
565- longitude : '9' ,
566- latitude : '10'
582+ longitude : 9 ,
583+ latitude : 10
567584 }
568585 } ]
569586 ) ;
0 commit comments