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

youtube-livechat-emitter

v0.1.12

Published

The simple emitter to emit the events of YouTube LiveChat

Readme

youtube-livechat-emitter

The simple emitter to emit the events of YouTube LiveChat.

Getting Started

Install

npm i youtube-livechat-emitter

Import and create instance

import { YoutubeLiveChatEmitter } from "youtube-livechat-emitter";

const channelId = "@channelHandle"; // not handle style is also valid.
const timeoutMilliSeconds = 1 * 1000; // polling interval to fetch live chat data

const emitter = new YoutubeLiveChatEmitter(channelId, timeoutMilliSeconds);

Set event listeners you want to observe. There are 12 kind of events.

  1. start

start event will be emitted when emitter starts successfully. No parameters passed to listener function.

emitter.on("start", () => {
  // do something.
});
  1. end

end event will be emitted when emitter stops the job. No parameters passed to listener function.

emitter.on("end", () => {
  // do something.
});
  1. error

error event will be emitted when something wrong caused in emitter's job. Error parameter passed to listener function.

emitter.on("error", (err: Error) => {
  // do something.
});
  1. addChat

addChat event will be emitted when someone chats, do super chat or do super sticker. LiveChatItem parameter passed to listener function.

You can know what kind of item via type field.

emitter.on("error", (item: LiveChatItem) => {
  // do something.
});
  1. removeChat

removeChat event will be emitted when a chat removed. LiveChatItemId parameter passed to listener function. It is identifier of which LiveChatItem instance.

emitter.on("removeChat", (id: LiveChatItemId) => {
  // do something.
});
  1. blockUser

blockUser event will be emitted when streaming owner bans someone. ChannelId parameter passed to listener function. It is Youtube channel id whose banned.

emitter.on("blockUser", (channelId: ChannelId) => {
  // do something.
});
  1. pinned

pinned event will be emitted when chat item pinned by streaming owner. ChatItemText parameter passed to listener function. It is item which pinned. ChatItemText is one of LiveChatItem.

emitter.on("pinned", (item: ChatItemText) => {
  // do something.
});
  1. unpinned

unpinned event will be emitted when pinned item is removed. Optionally ChatItemText parameter passed to listener function.

emitter.on("unpinned", (item?: ChatItemText) => {
  // do something.
});
  1. memberships

memberships event will be emitted when someone becomes member or someone reaches member's milestone. MembershipItem parameter passed to listener function. You can distinguish which event occurred by its type field.

emitter.on("memberships", (item: MembershipItem) => {
  // do something.
});
  1. sponsorshipsGift

sponsorshipsGift event will be emitted when someone purchases the gift. SponsorshipsGift parameter passed to listener function.

emitter.on("sponsorshipsGift", (item: SponsorshipsGift) => {
  // do something.
});
  1. redemptionGift

redemptionGift event will be emitted when someone consumes gift purchased by others. GiftRedemption parameter passed to listener function.

emitter.on("redemptionGift", (item: GiftRedemption) => {
  // do something.
});
  1. addTicker

addTicker event will be emitted when ticker item fixed to chat window. TickerItem parameter passed to listener function.

You can distinguish which kind of ticker by its type field.

The ticker items are belows:

  • purchased super chat
  • purchased super sticker
  • someone became new membership
  • purchased gift
emitter.on("addTicker", (item: TickerItem) => {
  // do something.
});

After registering listener functions, call start(). Since this time, emitter starts connection to external server.

emitter.start();

If you want to finish this emitter, call close().

emitter.close();

Here is a complete sample:

import { YoutubeLiveChatEmitter } from "youtube-livechat-emitter";

const channelId = "@CHANNEL_HANDLE";
const timeoutMilliSeconds = 1 * 1000;

const emitter = new YoutubeLiveChatEmitter(channelId, timeoutMilliSeconds);

emitter.on("error", (err) => {
  console.log("Error occurred.", err);
});

emitter.on("addChat", (item) => {
  switch (item.type) {
    case "text":
      console.log("Text", item);
      break;
    case "superChat":
      console.log("SuperChat", item);
      break;
    case "superSticker":
      console.log("SuperSticker", item);
      break;
  }
});

emitter.start();

setTimeout(() => {
  emitter.close();
}, 60 * 1000);