@fabianbormann/meerkat
TypeScript icon, indicating that this package has built-in type declarations

1.0.16 • Public • Published

Meerkat

Tests Release Bundle 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/latest/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)
  );
});

Package Sidebar

Install

npm i @fabianbormann/meerkat

Weekly Downloads

405

Version

1.0.16

License

Apache-2.0

Unpacked Size

4.35 MB

Total Files

10

Last publish

Collaborators

  • fabianbormann