https://github.com/vvo/chainit/blob/master/index.js#L99 shows that if the last argument is a function, we treat that as the callback.
However, consider this scenario:
// We have a callback added onto the function
chainit.add([object], name, function(string){
});
// function is treated as the final callback
chainit.add([object], name, function(string, function){
});
If I were to pass a string, the callback would be implemented for me:
chainit.add([object], name, function(string){
});
// the function gets called
function(string, cb){
});
but because I pass a function, this happens
chainit.add([object], name, function(function){
});
// the function gets called
function(cb){
});
This leads to confusion and means that sometimes it will be necessary to pass an empty function if you don't require a callback.
It would be better if it operated the same way the entire time.
EDIT: it could be fixed by just passing a boolean param to add()
if we want to use our function as the cb, or the generated one.
Here is perhaps a better example:
chainit.add([object], 'myFunction', function(param1, callback){
console.log(param1);
callback();
})
// Logs out the string, callback is defined
[object].myFunction(string);
// Logs out the function, callback is undefined
[object].myFunction(otherFunction);