New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ywasm

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ywasm - npm Package Compare versions

Comparing version 0.16.10 to 0.17.0

2

package.json

@@ -8,3 +8,3 @@ {

"description": "High performance implementation of the Yjs CRDT",
"version": "0.16.10",
"version": "0.17.0",
"license": "MIT",

@@ -11,0 +11,0 @@ "repository": {

@@ -13,34 +13,25 @@ # Ywasm

```js
import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm';
import * as Y from 'ywasm';
YDoc.prototype.transact = callback => {
const txn = this.beginTransaction()
try {
return callback(txn)
} finally {
txn.free()
}
}
const doc = new YDoc()
const doc = new Y.YDoc()
const text = doc.getText('name')
// append text to our collaborative document
text.insert(txn, 0, 'hello world')
text.insert(0, 'hello world', { bold: true })
// simulate update with remote peer
const remoteDoc = new YDoc()
const remoteDoc = new Y.YDoc()
const remoteText = remoteDoc.getText('name')
// in order to exchange data with other documents
// in order to exchange data with other documents
// we first need to create a state vector
const remoteSV = encodeStateVector(remoteDoc)
const remoteSV = Y.encodeStateVector(remoteDoc)
// now compute a differential update based on remote document's state vector
const update = encodeStateAsUpdate(doc, remoteSV)
const update = Y.encodeStateAsUpdate(doc, remoteSV)
// both update and state vector are serializable, we can pass them over the wire
// now apply update to a remote document
applyUpdate(remoteDoc, update)
Y.applyUpdate(remoteDoc, update)
const str = remoteText.toString(txn)
const str = remoteText.toString()
console.log(str)
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc