🚀 DAY 4 OF LAUNCH WEEK:Introducing Socket Scanning for OpenVSX Extensions.Learn more →
Socket
Book a DemoInstallSign in
Socket

@fabianbormann/meerkat

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fabianbormann/meerkat

Browser-to-browser networking built on WebTorrent

Source
npmnpm
Version
1.0.13
Version published
Maintainers
1
Created
Source

Meerkat

Tests conventionalcommits

Meerkat aims to be a typescript and webpack 5 friendly re-implementation of Bugout: A browser-to-browser networking built on WebTorrent

🚀 Getting Started

NPM

npm i @fabianbormann/meerkat

Broswer

<script src="https://fabianbormann.github.io/meerkat/meerkat.min.js"></script>
<script>
  const meerkat = new Meerkat({  ... });
</script>

🤖 Use Meerkat as a Server

import Meerkat from '@fabianbormann/meerkat';

const meerkat = new Meerkat({ seed: localStorage['bugout-demo-server-seed'] });
localStorage['meerkat-server-seed'] = meerkat.seed;

let connected = false;
meerkat.on('connections', (clients) => {
  if (clients === 0 && connected === false) {
    connected = true;
    console.log('[info]: server ready');
  }
  console.log(`[info]: ${clients} clients connected`);
});

meerkat.register('hello', (address, args, callback) => {
  console.log(
    `[info]: rpc call invoked by address ${address} into window.cardano`
  );
  callback('hello world');
});

console.log(`Share this address ${meerkat.address} with your clients`);

🥸 Use Meerkat as a Client

import Meerkat from '@fabianbormann/meerkat';

const meerkat = new Meerkat({ identifier: 'YOUR_SERVER_ADDRESS' });

meerkat.on('server', () => {
  console.log('[info]: connected to server');
  meerkat.rpc('YOUR_SERVER_ADDRESS', 'hello', {}, (response) =>
    console.log(response)
  );
});

Keywords

WebTorrent

FAQs

Package last updated on 05 Aug 2023

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