npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@andrewrivers/simple_webrtc

v0.4.3

Published

A light wrapper for WebRTC communication.

Readme

Simple WebRTC

A WebRTC wrapper that aims to be the as short and concise as possible.

installation (npm)

yarn add @andrewrivers/simple_webrtc

or..

npm i --save @andrewrivers/simple_webrtc

installation (es6)

import SimpleWebRTC from './simple_webrtc.js'

Standalone Release

usage

import SimpleWebRTC from '@andrewrivers/simple_webrtc'

const { Peer, Broadcast } = SimpleWebRTC()

const peer = Peer('local')
const offer = await peer.offer( )
const answer = await peer.answer( offer )

peer.open(answer)

peer.on('open', ( ) => ...)
peer.on('message', ( message ) => ...)
peer.on('error', ( error ) => ...)
peer.on('close', ( ) => ...)

peer.send({ abc: "def" })

Broadcast("hello world")

const camera = Peer.camera( )
const microphone = Peer.microphone( )
const screenshare = Peer.screen( )

peer.on('track', ({ streams }) => ...)

methods

connection

  • offer creates an offer, this is the first step in establishing a connection
const offer: string = await peer.offer()
  • answer creates an answer with offer, second step
const answer: string = await peer.answer(offer)
  • open establishes a connection with answer
await peer.open(answer)

send data

  • broadcast sends data to all peers
const data: object | string | number = { message: 'Hello World!' }
Broadcast(data)
  • peer.send sends data to a single peer
const data: object | string | number = { message: 'Hello World!' }
peer.send(data)

media

The UserMedia class supports callbacks as well as asynchronous functions. Each has an allow and block parameter, which are invoked depending on a user's prompt result. [MDN]

Peer.microphone( 
    ( stream: MediaStream ) => ... , // allow
    ( ) => ... // block
)
  • Peer.microphone adds the user's microphone's audio to a peer and returns its MediaStream, if unavailable or blocked returns null
const stream: MediaStream | void = await Peer.microphone()
  • Peer.camera adds the user's cameras's video to a peer and returns its MediaStream, if unavailable or blocked returns null
const stream: MediaStream | void = await Peer.camera()
  • Peer.screen prompts the user for a display/window/tab (with audio when available) and adds the user's choice to a peer and returns its MediaStream, if unavailable or blocked returns null
const stream: MediaStream | void = await Peer.screen()
  • Peer.custom uses custom constraints [MDN] to add the resulting MediaStream to a peer and returns its MediaStream, if unavailable or blocked returns null
const stream: MediaStream | void = await Peer.custom({
   video: true,  // default `false`
   audio: false, // default `false`
   screen: false // default `false`
})

callback syntax for Peer.custom:

Peer.custom( constraints, allow, block )

events

All events return async functions, so all events can be used in combination with await.

await peer.on('open')

Note that many of these events have no practical reason to be used this way, it is only for consistency and flexibility that it is provided.

  • open a connection has been established, following Peer.open()
peer.on('open', () => {
    /* connection established, can transceive data */
})
  • message data has been received, either by Peer.broadcast() or DataChannel.send()
peer.on('message', ( data: string | number | object ) => {
    /* if config.json is true, data will be parsed already */
})
  • icecandidate ICE candidate has been found, handled internally and can be ignored
peer.on('icecandidate', ( candidate: RTCIceCandidate ) => ... )
  • track track has been added via media [MDN]
peer.on('track', ({ streams } : { streams: MediaStream[] }) => ... )
  • error handled by config.debug
peer.on('error', ( method: string, message: string ) => ... )
  • log handled by config.log
peer.on('log', ( message: string ) => ... )

If you have any questions or you're having trouble getting set up, feel free to message me.

E-Mail: [email protected] Twitter: @Andr3wRiv3rs Discord: PoisonApple#9351