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

Consider refactoring many of these methods using some metaprogramming #2

Open
jhliberty opened this issue May 26, 2016 · 1 comment

Comments

@jhliberty
Copy link

Quite a few of the functions you define in index.js have the exact same signature except for a name property change... if you are manually writing these out consider refactoring to something like this function here. Reducing how many times you have to write things means less head to update without errors.

@jhliberty
Copy link
Author

Or better yet, use an es6 proxy could take care of that really easy.. Just trap out the construct and the apply calls.

On the constructor set the namespace just like you are doing now when you do new RedisNS('namespace', redisClient) and for the apply calls just take the namespace, add it to the key and Reflect the call back to the redisclient with the new namespaced key and you're good to go. No worrying about their implementation logic really at all... and it would be a fair bit less trouble to update

proxy
construct handler
apply handler

reflect

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

1 participant