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';
55export default function encodeCommand ( args : RedisCommandArguments ) : Array < RedisCommandArgument > {
66 const toWrite : Array < RedisCommandArgument > = [ ] ;
77
8- let strings = `* ${ args . length } ${ CRLF } ` ;
8+ let strings = '*' + args . length + CRLF ;
99
1010 for ( let i = 0 ; i < args . length ; i ++ ) {
1111 const arg = args [ i ] ;
1212 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 ;
1614 } 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 ;
2020 } else {
2121 throw new TypeError ( 'Invalid argument type' ) ;
2222 }
23-
24- strings += CRLF ;
2523 }
2624
2725 toWrite . push ( strings ) ;
Original file line number Diff line number Diff line change @@ -123,7 +123,11 @@ export function transformCommandArguments<T>(
123123}
124124
125125export 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+ } ) ;
127131}
128132
129133export function transformCommandReply < C extends RedisCommand > (
You can’t perform that action at this time.
0 commit comments