When text input changes, the following premises are usually true:
- If the new text is longer than the old, it means something was inserted
- If the new text is shorter than the old, it means something was removed
input-diff
finds the LCS when those premises are met, and a valid diff when they're not, with few iterations.
var diff = require('input-diff'),
data;
data = diff.get('Hello','Hello world');
console.log( diff.apply('Hello',data) ); // Hello world