-
Notifications
You must be signed in to change notification settings - Fork 52
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
Callback should be the last argument #53
Comments
I agree, but for now, it's done for backwards compatability, since some parameters were added after the fact. See #50 for a short discussion on the matter. I plan on making this change eventually, and am more than happy to merge pull requests so long as they either maintain backwards compatability or have a reasonable upgrade path (even if either is hacky for now). |
I think the long-term solution to this is to release a major release (1.0.0 type stuff), which breaks backwards compatibility. Semantic Versioning typically works this way: major releases which increase the first number are expected to introduce backwards-compatibility breaking behaviors. |
Amit, I think there are four options here:
In terms of what the ideal function interfaces should look like (ignoring backwards compatibility for now). Once we choose a style, I think we just make a break changing with a version between or two with deprecations for migration time. |
We now declare methods generally as: function(key, value, options, callback) Rather than adding each argument (generally unused) as trailing arguments after callback. Callback is _always_ the last argument now. To handle backwards compatability, we check the type of `options` and if it is a function, we treat arguments as corresponding to the old interface but issue a depreceated warning. This fixes issue #53 and #50, making CAS also easier to support going forward.
We now declare methods generally as: function(key, value, options, callback) Rather than adding each argument (generally unused) as trailing arguments after callback. Callback is _always_ the last argument now. To handle backwards compatability, we check the type of `options` and if it is a function, we treat arguments as corresponding to the old interface but issue a depreceated warning. This fixes issue #53 and #50, making CAS also easier to support going forward.
We now declare methods generally as: function(key, value, options, callback) Rather than adding each argument (generally unused) as trailing arguments after callback. Callback is _always_ the last argument now. To handle backwards compatability, we check the type of `options` and if it is a function, we treat arguments as corresponding to the old interface but issue a depreceated warning. This fixes issue #53 and #50, making CAS also easier to support going forward.
Having something other than a callback as the last function argument goes against node conventions and it's inconsistent with other methods in the module that have callback as the last argument.
The text was updated successfully, but these errors were encountered: