Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vinayv-456/operational-transformations
Operational Transformations (OT) for shared documents/editors
https://github.com/vinayv-456/operational-transformations
javascript nodejs
Last synced: about 2 months ago
JSON representation
Operational Transformations (OT) for shared documents/editors
- Host: GitHub
- URL: https://github.com/vinayv-456/operational-transformations
- Owner: vinayv-456
- Created: 2024-02-03T19:35:11.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-02-03T19:54:48.000Z (12 months ago)
- Last Synced: 2024-10-16T18:50:13.005Z (3 months ago)
- Topics: javascript, nodejs
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Operational Transformations (OT)
When people code together on shared code editor, everyone's code needs to be in sync. You have to see the same code as I do even though we're typing on different computers. The challenge is making sure we don't end up with a jumbled mess of text while we type together.
So in order to keep everyone's code in sync, a method called Operational Transformations, or OT can be used.
Think about OT like this: when you type, you can either insert text, delete text, or move your cursor to a new position (this is called skip in OT land). These actions are called operations, and they transform your document!
More concretely, you can look at an Operational Transformation as a function that takes in a document, a position within that document (like where your cursor is), and then either modifies the document at that position or skips to a new position.
## Examples
1. **Insert Operation:**
- Input document: ""
- Starting cursor position: 0
- Operation: {"op": "insert", "chars": "Hello, human!"}
- Output document: "Hello, human!"
- Ending cursor position: 132. **Delete Operation:**
- Input document: "What is up?"
- Starting cursor position: 7
- Operation: {"op": "delete", "count": 3}
- Output document: "What is?"
- Ending cursor position: 7
(*Note: Delete operations are applied forward while keeping the cursor in place.*)3. **Skip and Insert Operations:**
- Input document: "Nice!"
- Starting cursor position: 0
- Operation (1): {"op": "skip", "count": 4}
- Operation (2): {"op": "insert", "chars": " day"}
- Output document: "Nice day!"
- Ending cursor position: 8In the final example, two transformations are applied consecutively, showcasing the versatility of Operational Transformations.