Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

manymerge

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

manymerge - npm Package Compare versions

Comparing version 2.5.1 to 2.5.2

8

dist/hub.js

@@ -23,4 +23,6 @@ "use strict";

let ourDoc = doc;
// Convert clock to Immutable Map in case its been serialized
const msgClock = immutable_1.fromJS(msg.clock);
// 0. We should immediately update the clock of our peer.
this._theirClocks = this._theirClocks.set(peerId, msg.clock);
this._theirClocks = this._theirClocks.set(peerId, msgClock);
// 1. If they've sent us changes, we'll try to apply them.

@@ -42,3 +44,3 @@ if (msg.changes) {

// we should send it to them.
const ourChanges = automerge_clocks_1.recentChanges(doc, msg.clock);
const ourChanges = automerge_clocks_1.recentChanges(doc, msgClock);
if (ourChanges.length > 0) {

@@ -53,3 +55,3 @@ this.sendMsgTo(peerId, {

// them to send us changes via 2. listed above.
if (automerge_clocks_1.later(msg.clock, this._ourClock)) {
if (automerge_clocks_1.later(msgClock, this._ourClock)) {
this.broadcastMsg({

@@ -56,0 +58,0 @@ clock: this._ourClock

@@ -32,2 +32,22 @@ "use strict";

});
test("The hub can handle serialized messages", () => {
const peerSendMsg = jest.fn();
const peer = new peer_1.Peer(peerSendMsg);
// send an update
peer.notify(automerge_1.change(automerge_1.init(), doc => {
doc.name = "my-doc";
}));
// We just sent this message
const [clientMsg] = peerSendMsg.mock.calls[0];
expect(clientMsg.changes.length).toBe(1);
// Check that a hub can get the message back
const hubSendMsg = jest.fn();
const hubBroadcastMsg = jest.fn();
const hub = new hub_1.Hub(hubSendMsg, hubBroadcastMsg);
// Convert the client message to plain JSON
const jsClientMsg = JSON.parse(JSON.stringify(clientMsg));
const newDoc = hub.applyMessage("my-peer", jsClientMsg, automerge_1.init());
// Check that the clocks were updated and match
expect(hub._theirClocks.get("my-peer").toJS()).toEqual(automerge_clocks_1.getClock(newDoc).toJS());
});
test("The hub can broadcast it's clock to an unknown peer.", () => {

@@ -34,0 +54,0 @@ const hubSendMsg = jest.fn();

@@ -17,2 +17,4 @@ "use strict";

let ourDoc = doc;
// Convert msg clock to Immutable Map incase its been serialized
const msgClock = immutable_1.fromJS(msg.clock);
// 1. If they've sent us changes, we'll try to apply them.

@@ -24,3 +26,3 @@ if (msg.changes) {

// we should send it to them.
const ourChanges = automerge_clocks_1.recentChanges(doc, msg.clock);
const ourChanges = automerge_clocks_1.recentChanges(doc, msgClock);
if (ourChanges.length > 0) {

@@ -36,3 +38,3 @@ this.sendMsg({

const ourClock = automerge_clocks_1.getClock(ourDoc);
if (automerge_clocks_1.later(msg.clock, ourClock)) {
if (automerge_clocks_1.later(msgClock, ourClock)) {
this.sendMsg({

@@ -39,0 +41,0 @@ clock: ourClock

{
"name": "manymerge",
"version": "2.5.1",
"version": "2.5.2",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "author": "Evan Conrad",

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