The implementation language is Javascript. I have to transmit long hexadecimal strings (actually format is not important as I can convert to any format at the transmitting end and reconvert on the receiving end) at regular interval. As these hexastrings are almost the same, it is not optimal to send them as-is. Rather I would like to send a diff.
Here is pseudo code:
setInterval(function() {
//Using websocket, send message to server
sendSomeMessage(myHexString);
}, 10000);
Here myHexString is computed asynchronously. It may or may not change within the interval. That part is easy to optimize. I can just compare to the previous version and suppress the sending. What I need is the ability to send only diffs, when the change is actually there, as in:
setInterval(function() {
//Using websocket, send message to server
myDiff = diff(oldString, newString);
if (myDiff.length > 0)
sendSomeMessage(myDiff);
}, 10000);
At the receiving end, I will have code as in:
newVersion = getNewVersion(oldVersion, myDiff);
I found some diff libraries in Javascript but they do just that: Display the difference. I want the ability to apply the diff result to one content and get the target content. EDIT: Would be nice to have something in Javascript which implements Linux diff and patch.