text-history
Keeps track of changes to text so you can pull specific versions and patch an old version
- Retrieve any version
- Get patches to transform any version to the last version added
- Changes stored with deltas to save space
var TextHistory = ; var history = ;var id1 = history;var id2 = history; console;console; var patches = history;// diff_match_patch is a different moduleconsole;
TextHistory
new TextHistory()
Construct a new TextHistory object.
history.addVersion(text)
Add a new, updated version of the text. Returns a string id used to access the version again.
history.getVersion(id)
Retrieve text from the version of id. Returns undefined
if version id does not exist.
history.hasVersion(id)
Returns boolean value whether the version id exists or not.
history.lastVersion
The text of the latest version (last added) in the history.
history.getPatches(id)
Get the patches to transform the text of version id
into the last version. Returns an array of patches than can be used in google-difff-patch-match to patch a version to the lastest version.