@@ -661,37 +661,26 @@ function Command(command, args, sub_command, buffer_args, callback) {
661
661
}
662
662
663
663
RedisClient . prototype . send_command = function ( command , args , callback ) {
664
- var arg , command_obj , i , elem_count , buffer_args , stream = this . stream , command_str = "" , buffered_writes = 0 , last_arg_type ;
665
-
666
- if ( typeof command !== "string" ) {
667
- throw new Error ( "First argument to send_command must be the command name string, not " + typeof command ) ;
668
- }
669
-
670
- if ( Array . isArray ( args ) ) {
671
- if ( typeof callback === "function" ) {
672
- // probably the fastest way:
673
- // client.command([arg1, arg2], cb); (straight passthrough)
674
- // send_command(command, [arg1, arg2], cb);
675
- } else if ( ! callback ) {
676
- // most people find this variable argument length form more convenient, but it uses arguments, which is slower
677
- // client.command(arg1, arg2, cb); (wraps up arguments into an array)
678
- // send_command(command, [arg1, arg2, cb]);
679
- // client.command(arg1, arg2); (callback is optional)
680
- // send_command(command, [arg1, arg2]);
681
- // client.command(arg1, arg2, undefined); (callback is undefined)
682
- // send_command(command, [arg1, arg2, undefined]);
683
- last_arg_type = typeof args [ args . length - 1 ] ;
684
- if ( last_arg_type === "function" || last_arg_type === "undefined" ) {
685
- callback = args . pop ( ) ;
686
- }
687
- } else {
688
- throw new Error ( "send_command: last argument must be a callback or undefined" ) ;
689
- }
690
- } else {
691
- throw new Error ( "send_command: second argument must be an array" ) ;
664
+ var arg , command_obj , i , elem_count , buffer_args , stream = this . stream , command_str = "" , buffered_writes = 0 ;
665
+
666
+ // if (typeof callback === "function") {}
667
+ // probably the fastest way:
668
+ // client.command([arg1, arg2], cb); (straight passthrough)
669
+ // send_command(command, [arg1, arg2], cb);
670
+ if ( args === undefined ) {
671
+ args = [ ] ;
672
+ } else if ( ! callback && typeof args [ args . length - 1 ] === "function" ) {
673
+ // most people find this variable argument length form more convenient, but it uses arguments, which is slower
674
+ // client.command(arg1, arg2, cb); (wraps up arguments into an array)
675
+ // send_command(command, [arg1, arg2, cb]);
676
+ // client.command(arg1, arg2); (callback is optional)
677
+ // send_command(command, [arg1, arg2]);
678
+ // client.command(arg1, arg2, undefined); (callback is undefined)
679
+ // send_command(command, [arg1, arg2, undefined]);
680
+ callback = args . pop ( ) ;
692
681
}
693
682
694
- if ( callback && process . domain ) {
683
+ if ( process . domain && callback ) {
695
684
callback = process . domain . bind ( callback ) ;
696
685
}
697
686
0 commit comments