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

Better (More accurate) Documentation for Command.setArgumentTransformer #100

Closed
marcoslhc opened this issue Jul 12, 2015 · 1 comment
Closed

Comments

@marcoslhc
Copy link

If you run the example straight from the readme.md, setArgumentTransformer throws an error:

Redis.Command.setArgumentTransformer('hmset', function (args) {
             ^
TypeError: Cannot read property 'setArgumentTransformer' of undefined
    at Object.<anonymous> (/Users/marcoslh/Dropbox/fineappsco/auth/lib/db/index.js:8:14)
    at Module._compile (module.js:431:26)
    at Object.Module._extensions..js (module.js:449:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/marcoslh/Dropbox/fineappsco/auth/tests/db.js:3:12)
    at Module._compile (module.js:431:26)
    at Object.Module._extensions..js (module.js:449:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at /usr/local/lib/node_modules/mocha/lib/mocha.js:192:27
    at Array.forEach (native)
    at Mocha.loadFiles (/usr/local/lib/node_modules/mocha/lib/mocha.js:189:14)
    at Mocha.run (/usr/local/lib/node_modules/mocha/lib/mocha.js:422:31)
    at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:398:16)
    at Module._compile (module.js:431:26)
    at Object.Module._extensions..js (module.js:449:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:472:10)
    at startup (node.js:124:18)
    at node.js:959:3

and there's no other reference to Command.

Also the line:

      return [args[0]].concat(utils.convertMapToArray(args[1]));

requires utils definition. Looking into the source, the only way I see is to import this is by using the local utils module: const utils = <app-dir>/node_modules/ioredis/lib/utils (or maybe is lack of imagination, I was working late yesterday).
Am I missing something?

@luin luin closed this as completed in e0d8c9c Jul 12, 2015
@luin
Copy link
Collaborator

luin commented Jul 12, 2015

Oops, it seems Command hasn't been exported correctly for a long time. Just fixed it. Thank you for pointing it out.

utils.convertMapToArray is an internal module of ioredis. The code snippet is just a sample telling people how to use setArgumentTransformer. Added a comment in the Readme. 😄

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