Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to pass in an array of vals instead of as separate params #26

Merged
merged 2 commits into from Dec 22, 2014
Merged

Add ability to pass in an array of vals instead of as separate params #26

merged 2 commits into from Dec 22, 2014

Conversation

toddbluhm
Copy link
Contributor

  • Fixed so del now accepts an array of keys rather than just lots of
    params (should work for other commands too)
  • Added test cases for the del command, testing both multiple params
    and one array param
  • Updated .gitignore to include node_modules

- Fixed so del now accepts an array of keys rather than just lots of
params (should work for other commands too)
- Added test cases for the del command and testing both multiple params
and one array param
- Updated .gitignore to include node_modules
return this.send(command, slice.call(arguments, 0));
var args = slice.call(arguments, 0);
if(args.length && Array.isArray(args[0])) {
return this.send(command, args.shift().concat(args));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I've been handling this before now is by defining small wrapper methods around commands that accept multiple keys. e.g. see the implementation of MGET. That way we only do the extra work on commands that may need it instead of all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I tried to take a more general approach to the problem to solve this issue for other commands that might take arrays. I will do the wrapper style :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, let's stick with the existing style. Thanks!

Michael Jackson
@mjackson

On Fri, Dec 19, 2014 at 3:58 PM, Todd Bluhm notifications@github.com
wrote:

In modules/Client.js
#26 (diff):

@@ -212,7 +212,11 @@ require('redis/lib/commands').forEach(function (command) {

Object.defineProperty(Client.prototype, command, {
value: function () {

  •  return this.send(command, slice.call(arguments, 0));
    
  •  var args = slice.call(arguments, 0);
    
  •  if(args.length && Array.isArray(args[0])) {
    
  •    return this.send(command, args.shift().concat(args));
    

Yeah I tried to take a more general approach to the problem to solve this
issue for other commands that might take arrays. I certainly can do a
wrapper style like that if you would prefer?


Reply to this email directly or view it on GitHub
https://github.com/mjackson/then-redis/pull/26/files#r22136618.

@mjackson
Copy link
Owner

@toddbluhm Perfect. Thank you!

mjackson added a commit that referenced this pull request Dec 22, 2014
Add ability to pass in an array of vals instead of as separate params
@mjackson mjackson merged commit 3fecfaa into mjackson:master Dec 22, 2014
@mjackson
Copy link
Owner

@toddbluhm Just a heads up, this work is included in version 1.2.0, just released. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants