Skip to content

Optional callback when using Array args #321

@steelThread

Description

@steelThread

Quick question regarding client's supplying an optional callback when sending commands args via an Array. The optional callback doesn't appear to be optional anymore for me in this case:

client.del(['key1', 'key2']);

// or
client.del(['key1', 'key2'], undefined);

Which results in 351566259.101886 "del" "key1,key2" in the MONITOR. In this case I was expecting the Array to be expanded.

This worked at some point but after a recent upgrade I'm noticing it is no longer legit due to the following logic:

RedisClient.prototype[command] = function (args, callback) {
      if (Array.isArray(args) && typeof callback === "function") {
          return this.send_command(command, args, callback);
      } else {
          return this.send_command(command, to_array(arguments));
      }
};

Which will wrap the Array of args in another Array when the callback is not a function, hence what I'm seeing in the monitor. Is the function check on the callback necessary here? Maybe I'm missing something?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions