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

js-tariffs

v1.0.0

Published

[![Tariffs Enabled](https://img.shields.io/badge/import%20tariffs-active-orange?style=flat-square)](#)

Readme

npm-tariff

Tariffs Enabled

A “trade-war simulator” for Node.js.
Inject delays, quotas, and comedic messages when importing packages – as if they’re being taxed at customs. ~~> WARNING: This is purely satire and not recommended for production. Unless you enjoy forging comedic chaos in your CI pipeline!~~

Features

  • Tariff Delays
    Slow down imports of specific packages with an artificial “tariff” percentage.
  • Import Quotas
    Enforce a max number of times you can require a certain package. Exceed it, face an “import privilege revoked” message, and an exit(1).
  • Single Tweet
    At the end of the script, print one random ASCII tweet about tariffs, instead of spamming logs for each import.
  • Trade‑Deficit Dashboard
    On exit, show a summary of:
    • Which packages you “taxed” or “capped”
    • Total base load time vs. total artificially delayed time
    • A final comedic remark

Installation

npm install npm-tariff

Or if you’d rather link it during local dev:

# In your clone of npm-tariff
npm link

# In your test project
npm link npm-tariff

Usage

  1. Opt-In via --require
    Run your code like so, ensuring it’s required before your code:

    node --require npm-tariff yourScript.js

    This preloads npm-tariff, letting it monkey‑patch the loader.

  2. Programmatic API
    In your script, you can do:

    const tariff = require('npm-tariff');
       
    // Tariffs
    tariff.setTariffs({
      lodash: 100, // 100% => artificially adds 100 ms (by default) 
      axios: 200   // 200% => 200 ms
    });
       
    // Quotas
    tariff.setQuota({
      lodash: 2    // only allow requiring 'lodash' 2 times
    });
       
    // If you haven't already preloaded it via --require,
    // enable the monkey-patch manually:
    tariff.enable();
    
    console.log('--- Importing lodash first time ---');
    require('lodash');
    
    console.log('--- Importing axios ---');
    require('axios');
    
    console.log('--- Importing lodash second time ---');
    require('lodash');
    
    console.log('--- Importing lodash third time (should fail) ---');
    require('lodash');
  3. Auto‑enable
    By default, if npm-tariff is loaded before your main code (via --require), it automatically calls enable() so you don’t have to.

Demo

node --require npm-tariff demo.js

Possible Output:

--- Importing lodash first time ---
🛃  [npm‑tariff] Applying 100% tariff on "lodash" (100ms)
🕒  Base: 12ms → After tariff: 112ms (delay = 100ms)
--- Importing axios ---
🛃  [npm‑tariff] Applying 200% tariff on "axios" (200ms)
🕒  Base: 46ms → After tariff: 246ms (delay = 200ms)
--- Importing lodash second time ---
🛃  [npm‑tariff] Applying 100% tariff on "lodash" (100ms)
🕒  Base: 1ms → After tariff: 101ms (delay = 100ms)
--- Importing lodash third time (should fail) ---

❌  [npm‑tariff] Import quota exceeded for "lodash"
    Allowed: 2, Attempted: 3
    Your import privileges have been revoked. 🇺🇸💼

================ Trade‑Deficit Dashboard ================
lodash          x2  | base: 13ms | delay: 200ms
axios           x1  | base: 46ms | delay: 200ms
--------------------------------------------------------
   Grand Base Time : 59 ms
   Grand Delay     : 400 ms
========================================================

🗣️  Final Word On Tariffs: (ง'̀-'́)ง  WE'RE GONNA MAKE IMPORTS GREAT AGAIN!

API

interface Tariff {
  setTariffs(table: Record<string, number>): void;
  setQuota(table: Record<string, number>): void;
  enable(): void;
  disable(): void;
}

| Method | Description | |-------------:|:-----------------------------------------------------------------| | setTariffs | Provide a mapping: { pkgName: percentage }. 100 means +100ms. | | setQuota | Provide a mapping: { pkgName: maxImports }. Exceed = error. | | enable | Monkey‑patch Node’s loader, applying tariffs & quotas. | | disable | Revert to Node’s standard loader. No more import overhead. |

FAQ

  1. Why block the event loop with synchronous sleeps?
    If you actually wanted to do something useful, an async approach might be better.

  2. Why do I see random internal Node modules in the dashboard?
    We intentionally filter them out in the newest version, but if you do see them, it’s because Node is requesting internal modules. To hide them, only track stats for the modules you explicitly tariff/quota.

  3. Safe for production?
    Absolutely not recommended. Use at your own risk.

  4. What’s with the “import privileges have been revoked” message?
    That’s the point its called “quota limit.”

Contributing

Feel free to open issues or PRs to:

  • Add more comedic ASCII art
  • Adjust the base latency or randomize it
  • Add more “trade policy” toggles (like weekend surcharges, random “trade embargo” errors, etc.)

License

MIT – Because everyone wants stuff to be free. Enjoy your tariff wars!