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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tariff-njs

v1.0.0

Published

**Tariff-NJS** 是一个恶搞的 Node.js 包,用于给 `require` 函数添加“关税”。通过配置关税比例,指定的模块在被 `require` 导入时会增加额外的耗时,模拟“关税”效果。

Downloads

6

Readme

Tariff-NJS

Tariff-NJS 是一个恶搞的 Node.js 包,用于给 require 函数添加“关税”。通过配置关税比例,指定的模块在被 require 导入时会增加额外的耗时,模拟“关税”效果。

功能

  • 动态关税:为指定模块设置关税比例,影响其导入耗时。
  • 实时调整:支持动态增加或移除关税配置。
  • 简单易用:通过简单的 API 调用即可实现关税功能。

安装

npm install tariff-njs

使用示例

const tariff = require("tariff-njs");
const { percent } = require("tariff-njs");

// 为模块设置关税比例
tariff.increaseBy({
    axios: percent(200) // 设置 axios 模块的关税为 200%
});

// 测试导入耗时
console.log(
    "导入 axios 的耗时:",
    tariff.timer(() => require("axios"))
);

// 移除关税配置
tariff.cancel("axios");

API

increaseBy(newConfig: Configer): Configer

为指定模块设置关税比例。

  • newConfig:一个对象,键为模块名,值为关税比例(如 percent(200) 表示 200%)。

cancel(...name: string[]): boolean

移除指定模块的关税配置。

  • name:一个或多个模块名。

timer(executor: () => any): number

测量指定代码块的执行时间(单位:毫秒)。

percent(num: number): number

将百分比转换为小数形式。

注意事项

  • 关税耗时的实现是靠阻塞线程,会直接影响应用性能,不要在生产环境使用。

许可证

MIT License

Readme written by GPT-4o