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 🙏

© 2026 – Pkg Stats / Ryan Hefner

whip-whap-js

v1.0.1

Published

Small, simple JS library for initiating WHIP and WHAP WebRTC sessions

Readme

WHIP-WHAP-JS: WebRTC WHIP and WHAP using Perfect Negotiation

Features

  • Does NOT encapsulate RTCPeerConnection
  • Small, simple code base
  • Auto-retries WHIP/WHAP on WebRTC failure, or when iceConnectionState is "disconnected"
  • Uses Perfect Negotiation for WHIP and WHAP as from the Jan-Ivar Bruaroey article here

WHIP

WHIP stands for WebRTC-HTTP ingestion protocol It's an IETF draft, and you can learn more here: https://github.com/wish-wg/webrtc-http-ingest-protocol

WHAP

WHIP stands for WebRTC-HTTP access protocol And this is the only place to learn about it for now. It's similar to WHIP, but intended for receiving audio/video from WebRTC servers. See the example below.

WHIP Example

WHIP example: send camera to WHIP server.


let url = '/pub'
let whipwhap = await import('https://cdn.jsdelivr.net/npm/whip-whap-js')
document.write('<video id="video1" autoplay controls muted width="1024" allowfullscreen/>')
let pc = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] })
pc.addEventListener('iceconnectionstatechange', whipwhap.handleIceStateChange)
pc.addEventListener('negotiationneeded', ev => whipwhap.handleNegotiationNeeded(ev, url))
let gum = await navigator.mediaDevices.getUserMedia({ audio: true, video: true })
pc.addTransceiver(gum.getVideoTracks()[0], { 'direction': 'sendonly' })
pc.addTransceiver(gum.getAudioTracks()[0], { 'direction': 'sendonly' })
let video1 = document.getElementById('video1')
video1.srcObject = gum
video1.play()

WHAP Example

WHAP example: receive video/audio from WebRTC server to HTML video element.


let url = '/sub'
let whipwhap = await import('https://cdn.jsdelivr.net/npm/whip-whap-js')
document.write('<video id="video1" autoplay controls muted width="1024" allowfullscreen/>')
let pc = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] })
pc.addTransceiver('video', { 'direction': 'recvonly' }) // build sdp
pc.addTransceiver('audio', { 'direction': 'recvonly' }) // build sdp
pc.addEventListener('iceconnectionstatechange', whipwhap.handleIceStateChange)
pc.addEventListener('negotiationneeded', ev => whipwhap.handleNegotiationNeeded(ev, url))
let video1 = document.getElementById('video1')
pc.ontrack = ev => video1.srcObject = ev.streams[0]

Functions

whip-whap-js

WHIP WHAP module.

whip-whap-js~handleNegotiationNeeded(event, url)

Event handler for 'negotiationneeded' event.

Kind: inner method of whip-whap-js

| Param | Type | | --- | --- | | event | Event | | url | string |

Example

WHIP example
// pc.onnegotiationneeded = ev => whipwhap.handleNegotiationNeeded(ev, '/pub')

Example

WHAP example
// pc.onnegotiationneeded = ev => whipwhap.handleNegotiationNeeded(ev, '/sub')

whip-whap-js~handleIceStateChange(event)

Event handler for 'iceconnectionstatechange' event.

Kind: inner method of whip-whap-js

| Param | Type | | --- | --- | | event | Event |

Example

// pc.addEventListener('iceconnectionstatechange', whipwhap.handleIceStateChange)

whip-whap-js~helperGetRxTxRate(pc)

This is a helper function, which is not required to make WHIP or WHAP connections. It will return the current rx/tx bitrates the next time a getStats() event is available.

Kind: inner method of whip-whap-js

| Param | Type | | --- | --- | | pc | RTCPeerConnection |