Current collected state Current
Observed since 21 Oct, 08:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0xgg/korona
**Korona = Kill Corona (virus)**, to memorate those who fight against the corona virus bravely in 2020. 仅已此库纪念 2020 年那些勇敢与新冠状病毒抗争的人们。
Korona = Kill Corona (virus), to memorate those who fight against the corona virus bravely in 2020.
仅已此库纪念 2020 年那些勇敢与新冠状病毒抗争的人们。
Minimal library to quickly construct decentralized p2p network
$ npm install @0xgg/korona
Simple Korona P2P Chat application:
https://0xgg.github.io/korona/
Check the index.html for example usages.
import { Korona, randomId } from "@0xgg/korona";
// Initialize the Korona P2P network
const peer = new Korona({
peerId = randomId(), // The peerId, default to `randomId()`
roomId = "public-rrom", // The roomId, default to `undefined`. If specified, then the peer will try to join the PubSub room. The peer might become the PubSub room host if there is no host yet.
peerJSOptions: {
// Follows https://peerjs.com/docs/#peer-options
},
maxPeers: 5, // Max number of peer connections that your peer can have
});
// Get ready to be used
peer.on("open", async (peerId) => {
// When another peer just connected to you and tries to sync data with you,
// you send some data back.
peer.on("sync", async (send, peerId) => {
return send({
// ... data that you want to send
});
});
// When a new peer joined the P2P network
peer.on("peerJoined", async (peerId) => {
console.log(`${peerId} joined`);
});
// When a peer left the P2P network
peer.on("peerLeft", async (peerId) => {
console.log(`${peerId} left`);
});
// When your peer gets disconnnected from the server but keep the connections alive in the P2P network. Will not be able to accept new peer connections.
peer.on("disconnected", async () => {
// Do something
});
// Emitted when the peer is destroyed and can no longer accept or create any new connections. At this time, the peer's connections will all be closed.
peer.on("close", async () => {
// Do something
});
// When there is peer error: https://peerjs.com/docs/#peeron-error
peer.on("error", async (error) => {
// Do something
});
// When you receive data from other peers
peer.on("data", async (data: any) => {
// Do something
});
// When the PubSub host changed,
peer.on("pubsubHostChanged", async () => {
// Do something
});
// Join the P2P network that other peer lives in
await peer.requestConnection("target-peer-id");
// Broadcast the data to all other peers in the P2P network
await peer.broadcast({
// Data goes here
});
// Send data to specific peer by id
await peer.send("target-peer-id", {
// Data goes here
});
});
MIT
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
peerjsEnvironment{
"local_name": "peerjs",
"alias": false,
"peer_metadata": null
} | ^1.4.6 | runtime |
typed-emitterEnvironment{
"local_name": "typed-emitter",
"alias": false,
"peer_metadata": null
} | ^2.1.0 | runtime |
@rollup/plugin-jsonEnvironment{
"local_name": "@rollup/plugin-json",
"alias": false,
"peer_metadata": null
} | ^4.1.0 | development |
@rollup/plugin-node-resolveEnvironment{
"local_name": "@rollup/plugin-node-resolve",
"alias": false,
"peer_metadata": null
} | ^13.3.0 | development |
@rollup/plugin-typescriptEnvironment{
"local_name": "@rollup/plugin-typescript",
"alias": false,
"peer_metadata": null
} | ^3.0.0 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ^13.7.0 | development |
@types/peerjsEnvironment{
"local_name": "@types/peerjs",
"alias": false,
"peer_metadata": null
} | ^1.1.0 | development |
http-serverEnvironment{
"local_name": "http-server",
"alias": false,
"peer_metadata": null
} | ^14.1.1 | development |
huskyEnvironment{
"local_name": "husky",
"alias": false,
"peer_metadata": null
} | ^8.0.1 | development |
rollupEnvironment{
"local_name": "rollup",
"alias": false,
"peer_metadata": null
} | ^2.77.2 | development |
rollup-plugin-polyfill-nodeEnvironment{
"local_name": "rollup-plugin-polyfill-node",
"alias": false,
"peer_metadata": null
} | ^0.10.2 | development |
tslibEnvironment{
"local_name": "tslib",
"alias": false,
"peer_metadata": null
} | ^2.4.0 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^4.7.4 | development |
Source distribution
{
"integrity": "sha512-LliU1Z5vKgByosOEQdPwfToQiT5IG3ZHGjNzkCTSuqBUWt4PrO6GSUS0ZAKy6/WBl8G2Ilzm94ANhCyFrrqDHA==",
"shasum": "0ed1d416fb787a491e3bbf535d7ae7592ec9b321",
"tarball": "https://registry.npmjs.org/@0xgg/korona/-/korona-0.0.7.tgz",
"fileCount": 86,
"unpackedSize": 355054,
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIQCEHQNYYD7GGiwBBd/LZNduh2CDk1+F141GmR7E4drpYgIgYGrRn810NpKaQmiO+wRI3lGGzQ6unYctQPF20i9YtqU="
}
],
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6p0LACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpcCQ/+MdF+40kL59JxL9s3LKP85b/4ih1QSEEHWli4QVtkgYsdJgtT\r\nkHaDLvoh8sHHig9vp9pNWJWXJmasLcA4GYvU7B1iuIhJqB5jHeKAqKO3qJFY\r\nxtvxk8FEM9Gme4CQkCgE/8mJ0aSXTGMtNgyjOHsirQLArh7LkqydzUD+P6c2\r\noksArFAoW0zLe9t6biEzjNq378CuzJlbEuzCfJ5NGC9Gu/peihmb8Kt8hrd7\r\nZMQpWBjWfp8yW2wF2CoHCtCL2C2LO4UDYbuCj9Koh34127iImygSEdhe3uMW\r\nz4NH55dbS0L7diIHBhjdnKoOpV4z5pEDOomL/x9diPdO5wQnKn+hPj36Xibb\r\nYFNlqGIPe0w6AzbextkPr2QSkn446D6KSMyVQex5YfxnQUMmFIi1TItIlH7Z\r\nVWaeFNcnMaWCCMoiOlJ629mr9JMvxRMSM6Yr5BsT28koH7MTmR6X//LSdTWt\r\nnwkSa8ZVEeBVer9ixBoqfB6o493fCx1BdvewERz5LlJzOd+Aws+spOEeNmlk\r\nYck3gajsuT9PCv1K1NiwOlHKxRAlJOM8F4SJEpFog4rmA2jzoUdjMNWulGn6\r\n9Xziq8SGp3Fckk5oyNYhYi81wiXW3k1Kq6ypRX8m+u1aQSHdF9bPuOO/YXoQ\r\nxl1fU+20JQvGjdm4GbrDZvnvk+O9tveTA5g=\r\n=vkxD\r\n-----END PGP SIGNATURE-----\r\n"
}Observed since 21 Oct, 08:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:d9792069b6bcea4a7f2d65ddfc1c9b2b4872fcbd0cd8ce500911e57162489aa4