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

Get without callback returns incorrect signature #141

Open
simonbrent opened this issue Jan 27, 2021 · 2 comments
Open

Get without callback returns incorrect signature #141

simonbrent opened this issue Jan 27, 2021 · 2 comments

Comments

@simonbrent
Copy link

The documentation for Client.prototype.get states:

// The callback signature is:
//
// callback(err, value, flags)

but the code contains the following:

  if(callback === undefined) {
    return promisify(function(callback) {
      self.get(key, function(err, value, flags) {
        callback(err, {value: value, flags: flags});
      });
    });
  }

Changing this to

  if(callback === undefined) {
    return promisify(function(callback) {
      self.get(key, callback)
    });
  }

would fix this issue.

@alevy
Copy link
Member

alevy commented Feb 5, 2021

Indeed! Can you send a pull request with this change? The alternative would be to change the comment, but the documented behavior seems like a better interface.

@simonbrent
Copy link
Author

I have tried, but it is more problematic than I thought, since you can't return multiple values from a Promise. I therefore don't think there's a way to be consistent with the signatures between the promisified version and the unpromisified version without changing the unpromisified version, which I imagine would be undesirable.

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

No branches or pull requests

2 participants