File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -5,23 +5,21 @@ const CRLF = '\r\n';
5
5
export default function encodeCommand ( args : RedisCommandArguments ) : Array < RedisCommandArgument > {
6
6
const toWrite : Array < RedisCommandArgument > = [ ] ;
7
7
8
- let strings = `* ${ args . length } ${ CRLF } ` ;
8
+ let strings = '*' + args . length + CRLF ;
9
9
10
10
for ( let i = 0 ; i < args . length ; i ++ ) {
11
11
const arg = args [ i ] ;
12
12
if ( typeof arg === 'string' ) {
13
- const byteLength = Buffer . byteLength ( arg ) ;
14
- strings += `$${ byteLength } ${ CRLF } ` ;
15
- strings += arg ;
13
+ strings += '$' + Buffer . byteLength ( arg ) + CRLF + arg + CRLF ;
16
14
} else if ( arg instanceof Buffer ) {
17
- toWrite . push ( `${ strings } $${ arg . length } ${ CRLF } ` ) ;
18
- strings = '' ;
19
- toWrite . push ( arg ) ;
15
+ toWrite . push (
16
+ strings + '$' + arg . length . toString ( ) + CRLF ,
17
+ arg
18
+ ) ;
19
+ strings = CRLF ;
20
20
} else {
21
21
throw new TypeError ( 'Invalid argument type' ) ;
22
22
}
23
-
24
- strings += CRLF ;
25
23
}
26
24
27
25
toWrite . push ( strings ) ;
Original file line number Diff line number Diff line change @@ -123,7 +123,11 @@ export function transformCommandArguments<T>(
123
123
}
124
124
125
125
export function transformLegacyCommandArguments ( args : Array < any > ) : Array < any > {
126
- return args . flat ( ) . map ( x => x ?. toString ?.( ) ) ;
126
+ return args . flat ( ) . map ( arg => {
127
+ return typeof arg === 'number' || arg instanceof Date ?
128
+ arg . toString ( ) :
129
+ arg ;
130
+ } ) ;
127
131
}
128
132
129
133
export function transformCommandReply < C extends RedisCommand > (
You can’t perform that action at this time.
0 commit comments