In Javascript, should appending to the signature of a callback be considered a breaking change?
I.e. given an operation op(target, callback) should changing it from callback(item, index, array) to callback(item, index, array, root) result in a new major release according to semver?
The spec specifies:
increment the MAJOR version when you make incompatible API changes
and the two signatures are not incompatible, as the new one encompasses the old, seeming to suggest a new major version is not required.
On the other hand, consider this (admittedly slightly contrived) example:
function doTheThing(item, index, array, doItDifferently) { if (doItDifferently) // Do something unusual and amazing with the arguments else // Do the same old boring thing with the arguments } // Use doTheThing as a callback to the operation: op(target, doTheThing) // doTheThing is also used directly: doTheThing(arr[0],0,arr,true) doTheThing is a valid callback, but might be used elsewhere in the code in its more elaborate form. This would break if the callback signature were changed.
Update
Wow, lots of really good food for thought. I see no consensus, but there seems to be a majority in favor of considering it a breaking change, and, hence, a major release. The more I have been thinking about it, the more that seems right to me, as well, and I think that is what I will do. It's definitely the safer option.
I had posted this as more or less an abstract question, not expecting it to spark so much debate. To facilitate further discussion, the library in question is object-selectors, a selector language for complex and deeply nested Javascript objects, and specifically, the perform operation.
opcalls it's parameter, or what your library passes toop?op, which is exported by my library, calls its callback parameter.