demotivator
demotivator is an open-source npm package containing a curated collection of insults organized into themed packs. It is maintained by PorkyProductions and licensed under the Apache License 2.0.
The package is designed to be reusable and extensible — it ships both raw insult data and utility functions for selecting, combining, and retrieving insults programmatically. It serves as the data layer for the (de)Motivator web app, but can be used independently in any JavaScript or TypeScript project.
Installation
Section titled “Installation”npm install demotivatorQuickstart
Section titled “Quickstart”There are three ways to use the package depending on your preference: named imports for tree-shaking, the deMotivator object for a namespace-style API, or the DeMotivator class for an instance-based approach.
Named Imports (recommended)
Section titled “Named Imports (recommended)”import { generateInsult, insults, createArray, makeAngry } from 'demotivator';
// Random insult from the original packconst insult = generateInsult(insults);
// Random insult from a custom combination of packsconst pool = createArray({ packs: ['original', 'halloween'] });const seasonalInsult = generateInsult(pool);const dramatic = makeAngry(seasonalInsult);Object API
Section titled “Object API”import deMotivator from 'demotivator';
const insult = deMotivator.generateInsult(deMotivator.insults);Class API
Section titled “Class API”import { DeMotivator } from 'demotivator';
const dm = new DeMotivator();
// Defaults to the 'original' pack when no array is providedconst insult = dm.generateInsult();Package Structure
Section titled “Package Structure”The package source lives in packages/demotivator/ within the monorepo and is published to npm as demotivator. Internally it is organized into four modules:
| Module | Purpose |
|---|---|
typings.ts | All TypeScript types and interfaces |
insults.ts | Raw insult arrays, pack definitions, and the pack registry |
generateinsult.ts | Functions for selecting insults from an array |
index.ts | Public API surface — re-exports, createArray, deMotivator object, and DeMotivator class |
Documentation Map
Section titled “Documentation Map”- Types — TypeScript type definitions and interfaces
- Packs — How the insult pack system works
- API Reference — Every exported function, object, and class