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

discrub-core

v1.0.1

Published

Core library powering [Discrub](https://github.com/prathercc/discrub-web) — a Discord data management tool for exporting, purging, and analyzing your Discord messages.

Readme

discrub-core

Core library powering Discrub — a Discord data management tool for exporting, purging, and analyzing your Discord messages.

Handles all Discord API communication, message processing, export data preparation, HTML formatting, reaction enrichment, and user data enrichment.

Installation

npm install discrub-core

Architecture

discrub-core/
  lib/
    services/       Discord API, GitHub gist, export data
    messages/       Message retrieval pipeline (fetch, enrich, modify)
    types/          TypeScript type definitions (Discord + Discrub)
    enum/           Enums (channel types, settings, export formats)
    utils/          Utility functions (formatting, HTML, settings)
    filtering/      Message search filter logic
    guards/         Type guard functions
    regex/          Discord markdown parsing regexes
    constants/      Discord search constants

Modules

Services

discord-service

Discord API v10 wrapper with rate limiting, retry logic, and configurable delays.

import { DiscordService } from 'discrub-core/discord-service';

const discord = new DiscordService(settings);
const messages = await discord.fetchMessages(token, channelId);
const guilds = await discord.fetchGuilds(token);

Handles: messages, guilds, channels, DMs, reactions, threads, search, user profiles, guild members.

github-service

Fetches announcement and donation data from GitHub Gists.

import { fetchDonationData, fetchAnnouncementData } from 'discrub-core/github-service';

const donations = await fetchDonationData();
const announcement = await fetchAnnouncementData();

export-data-service

Paginates messages into export pages with thread separation support.

import { prepareExportData } from 'discrub-core/export-data-service';

const result = prepareExportData(messages, config);
// result.pages — paginated message arrays
// result.threadExports — separated thread content

Message Pipeline (messages)

The core retrieval and enrichment pipeline, composed of specialized services:

MessageRetrievalService (orchestrator)
  ├─ MessageFetchService      — Search API pagination, thread discovery
  ├─ ReactionEnrichmentService — Fetch reaction user data per emoji
  └─ UserDataEnrichmentService — Fetch display names, nicknames, avatars

All services extend BaseServiceConfig:

interface BaseServiceConfig {
  apiClient: IDiscordAPIClient;
  token: string;
  onProgress?: ProgressCallback;
  onStatus?: StatusCallback;
  shouldStop?: ShouldStopCallback;
}

Modification Services

  • MessageModificationService — Edit and delete messages
  • ReactionModificationService — Remove reactions
  • PurgeService — Bulk message deletion and reaction removal with user targeting

Types

types/discord-types

Full Discord API type definitions: Message, Channel, Guild, User, Reaction, Embed, Attachment, etc.

import type { Message, Channel, Guild, User } from 'discrub-core/types/discord-types';

types/discrub-types

Discrub-specific types for export, settings, and enrichment:

import type {
  Donation,
  ExportReaction,
  ExportReactionMap,
  ExportUserMap,
  SearchCriteria,
  AppSettings,
} from 'discrub-core/types/discrub-types';

Enums

import { ChannelType, MessageType, ReactionType } from 'discrub-core/discord-enum';
import { DiscrubSetting, ExportType } from 'discrub-core/discrub-enum';
import { SortDirection } from 'discrub-core/common-enum';

Key enums:

  • ChannelType — GUILD_TEXT, DM, GUILD_VOICE, GUILD_FORUM, etc.
  • DiscrubSetting — All persisted settings keys (delays, export prefs, purge config)
  • ExportType — HTML, CSV, JSON, MEDIA

Utils

html-formatting-utils

Converts Discord markdown to HTML: bold, italic, code blocks, mentions, headings, links, spoilers, emojis.

import { formatContentAsHtml } from 'discrub-core/html-formatting-utils';

const html = formatContentAsHtml(message.content, formattingContext);

discrub-utils

General utilities: sorting, thread management, user formatting, permission checks, date helpers.

settings-utils

Typed accessors for string-based settings:

import { SettingsHelper } from 'discrub-core/utils/settings-utils';

const isEnabled = SettingsHelper.isEnabled(settings, DiscrubSetting.REACTIONS_ENABLED);
const delay = SettingsHelper.getNumber(settings, DiscrubSetting.SEARCH_DELAY, 2);

export-utils

Export-specific utilities: mention replacement, emoji HTML conversion.

message-formatting-utils

Discord message parsing: extract mentions, parse special formatting.

Filtering

import { updateFilters } from 'discrub-core/filtering';

const newFilters = updateFilters(currentFilters, newFilter);

Supports: text, date, toggle, array, and thread filter types.

Guards

import { isMessage, isGuild, isAttachment } from 'discrub-core/discrub-guards';
import { isNonNullable } from 'discrub-core/common-guards';

Configuration

Services are configured via settings objects. All settings are stored as strings (for localStorage/chrome.storage compatibility):

| Setting | Description | Default | |---------|-------------|---------| | SEARCH_DELAY | Seconds between search API calls | "2" | | DELETE_DELAY | Seconds between delete operations | "1" | | DELAY_MODIFIER | Random delay variance (seconds) | "0.5" | | REACTIONS_ENABLED | Fetch reaction user data during export | "true" | | DISPLAY_NAME_LOOKUP | Fetch display names for users | "false" | | SERVER_NICKNAME_LOOKUP | Fetch server nicknames | "false" |

Development

# Install dependencies
npm install

# Run tests (846 tests)
npm test

# Build
npx vite build

# Lint
npm run lint

Dependencies

  • date-fns — Date formatting and manipulation
  • highlight.js — Code block syntax highlighting in HTML exports
  • filenamify — Safe filesystem name generation
  • nanoid — Unique ID generation
  • copy-to-clipboard — Clipboard utilities

License

All rights reserved. © 2024-2026 prathercc. See LICENSE.

The source code in this repository is publicly visible for transparency and security review. discrub-core is published to npm to support Discrub's build pipeline; it is not licensed for use by other parties without explicit permission from the copyright holder.

"Discrub" and the Discrub logo are trademarks of prathercc.