Socket
Book a DemoInstallSign in
Socket

automerge-repo-network-peerjs

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

automerge-repo-network-peerjs

Network adapter for automerge-repo using peerjs

1.2.3
latest
npmnpm
Version published
Weekly downloads
51
5000%
Maintainers
0
Weekly downloads
 
Created
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

Package last updated on 12 Sep 2024

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.