
Herm document system

This module allow you to create a "git like" sync system for documents in JS with automatic conflict resolution. With this module, you can edit multiple instances of the same document and merge them in a queue, the module will solve the conflict by itself.
Installation
You can either use it via NPM (for Node or bundled modules)
npm install herm-js-document
or via ES6 modules
<script type="module">
import HermDoc from '//unpkg.com/herm-js-document';
let doc = new HermDoc();
</script>
Usage
For plain text :
let doc = new HermDoc();
doc.push(0, "Hello");
let doc2 = doc.duplicate();
doc.push(6, " world");
doc2.push(6, " !");
console.log("doc1 : ", doc.display());
console.log("doc2 : ", doc2.display());
doc = doc.merge(doc2);
console.log("doc(first merge) : ", doc.display());
doc2.push(7, "?");
console.log("doc2(updated) : ", doc2.display());
doc = doc.merge(doc2);
console.log("doc(merged with outdated) : ", doc.display());
doc.deleteRange(0, 6);
console.log("doc(delete) : ", doc.display());
For JSON :
let docJson = new HermJsonDoc();
docJson.key = "123";
console.log(docJson.display())
let docJson2 = docJson.duplicate();
docJson2.key = "5";
docJson2.key2 = "7";
docJson = docJson.merge(docJson2);
console.log(docJson.display())