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

media-pool

v0.1.0

Published

A pool of reusable media elements for the web.

Downloads

6

Readme

media-pool

A pool of reusable media elements for the web. This is akin to a thread pool in multi-threaded languages. A media player can request a media element (<video> or <audio>) from the pool. Once done it can release the element back into the pool.

The pool is optimized, so it lazy-releases a media-element; which means if the media player is active again it can reuse its old media-element even though it was released. This prevents re-attaching to DOM and re-loading videos/audios. In the case where the released media-element has been allocated to some other player, the media player will get a new one from the pool.

Read the blog post describing this media-pool

Install and Usage

Available on npm:

npm install media-pool --save

In your code:

import { VideoPool }  from 'media-pool'
// or for audio:
import { AudioPool }  from 'media-pool'

API

constuctor

Create a pool by optionally providing the size the pool. Default value is 5.

const videoPool = new VideoPool();
const audioPool = new AudioPool(10);

initializeNode(parent: HTMLElement, sources: MediaSource[]): HTMLMediaElement

This method will allocated a new media element with the provided source and appent the element as a child to the parent node provided. If the parent node already has a pool element as a child, that node is reused. HTMLMediaElement can be a HTMLVideoElement or an HTMLAudioElement based on which constructor was used.

setCurrent(media: HTMLMediaElement | null)

Let the pool know that this particular media element is the active player. Set to null if there is no active player.

release(media: HTMLMediaElement)

Release the element back to the pool. This will automatically pause the media. It will not remove the element from its parent in case it could be reused. But it will be removed when the pool runs out of unallocated elements.

play(media: HTMLMediaElement)

Plays the media.

pause(media: HTMLMediaElement)

Pauses the media.

restart(media: HTMLMediaElement)

Restarts the media from the begining.

mute()

Mute all media

unmute()

Unmutes current media element (if any). It will also bless other elements in the pool. For more about blessing, read the blog post

releaseAll()

Releases all media elements