@allior/wmake-streamelements-events
v0.0.3
Published
Twitch/StreamElements subscription event normalizer for widgets (alerts).
Maintainers
Readme
@allior/wmake-streamelements-events
Language / Язык: English | Русский
Twitch/StreamElements subscription event normalizer for widgets (alerts).
- shared — classification and tiers:
parseTier,getCacheKey,classifyEvent. - aggregate — buffer by
activityGroup, one normalized event per group (2.5 s timeout):normalizeIncomingEvent.
Ported from RishamonAlerts (event-normalizer-shared.js, event-normalizer-aggregate.js).
Installation
In the wmake repo the package is already in workspaces. From the root:
pnpm install
pnpm --filter @allior/wmake-streamelements-events buildUsage
import {
normalizeIncomingEvent,
classifyEvent,
getCacheKey,
parseTier,
} from "@allior/wmake-streamelements-events";
// detail = { listener: "event", event: { type: "subscriber", ... } }
normalizeIncomingEvent(
detail,
{ cacheSubs: cacheByType, broadcasterLogin: "mychannel" },
(normalized) => {
if (normalized) console.log(normalized);
},
);API
classifyEvent(detail)— returns the classified object ornull.getCacheKey(detail)— key for deduplication.parseTier(raw)—{ tier: 0|1|2|3, tierText }.normalizeIncomingEvent(detail, options, onNormalized)— buffers community-gift; for others callsonNormalizedimmediately (with cache).
