Socket
Socket
Sign inDemoInstall

automerge-repo-network-peerjs

Package Overview
Dependencies
65
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    automerge-repo-network-peerjs

Network adapter for automerge-repo using peerjs


Version published
Weekly downloads
45
increased by12.5%
Maintainers
1
Install size
19.2 MB
Created
Weekly downloads
 

Readme

Source

automerge-repo-network-peerjs

ci.node

A network adapter for WebRTC using peerjs, based on the point-to-point MessageChannelNetworkAdapter.

 

Setup

yarn add automerge-repo-network-peerjs

 

Usage

Establish a data connection as per peerjs documentation:

import { Peer } from "peerjs";
const peer = new Peer("pick-an-id");
const conn = peer.connect("another-peers-id");

Then use that to pass into the constructor of the automerge network adapter:

import { PeerjsNetworkAdapter } from "automerge-repo-network-peerjs";
const adapter = new PeerjsNetworkAdapter(conn);

Along with the usual NetworkAdapterInterface events an additional onData event is available to keep track of directional data being sent and received, for example:

function monitor(adapter: PeerjsNetworkAdapter, dispose$?: Observable) {
  const detach = adapter.onData((e) => console.log(`⚡️ ${e.direction}: ${e.bytes} bytes`));
  dispose$?.subscribe(detach);
}

 


Please Note:
This is not an official part of the automerge-repo project, rather a community contribution that includes a dependency on the peerjs library.

FAQs

Last updated on 20 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc