@cocreate/crdt 1.11.2 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.12.0](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.11.2...v1.12.0) (2022-07-03)
2
+
3
+
4
+ ### Features
5
+
6
+ * viewVersion function to return string of a specified version ([e652663](https://github.com/CoCreate-app/CoCreate-crdt/commit/e65266331c25baef10698e6234686a82b77ca4a6))
7
+
1
8
  ## [1.11.2](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.11.1...v1.11.2) (2022-06-18)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/crdt",
3
- "version": "1.11.2",
3
+ "version": "1.12.0",
4
4
  "description": "CoCreate crdt",
5
5
  "author": "CoCreate LLC",
6
6
  "license": "SEE LICENSE",
package/src/index.js CHANGED
@@ -396,6 +396,24 @@ function redoText(info){
396
396
  }
397
397
  }
398
398
 
399
+ async function viewVersion(data) {
400
+ try {
401
+ let name = docs.get(`${data.collection}${data.document_id}`).get(data.name);
402
+ let string = '';
403
+ let changeLog = name.get('changeLog');
404
+ let log = changeLog.slice(0, data.version)
405
+ for (let change of log) {
406
+ if (change || change !== null ) {
407
+ string = string.customSplice(change.start, change.length, change.value);
408
+ }
409
+ }
410
+ return { ...data, ...string }
411
+ }
412
+ catch (e) {
413
+ console.error(e);
414
+ }
415
+ }
416
+
399
417
 
400
418
 
401
419
  // function deleteDoc(docName) {
@@ -415,4 +433,4 @@ function generateDocName(info) {
415
433
  // return btoa(JSON.stringify(docName));
416
434
  }
417
435
 
418
- export default { init, getText, updateText, replaceText, undoText, redoText };
436
+ export default { init, getText, updateText, replaceText, undoText, redoText, viewVersion };