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

glowdown

v0.0.5

Published

A library for applying grayscale filter on memorial days

Readme

Glowdown 纪念日灰度化库

一个轻量级的TypeScript库,用于在特定纪念日自动为网页应用灰度滤镜效果。

功能特性

  • 根据配置的纪念日日期自动触发自定义行为
  • 支持从JSON文件加载纪念日数据
  • 必须明确提供onMemorialDay回调来自定义纪念日触发时的行为,库不再默认应用任何样式或效果。
  • 完全类型安全的TypeScript实现

安装

npm install glowdown
# 或
pnpm install glowdown
# 或
yarn add glowdown

使用方法

在Node.js中使用

import Glowdown from 'glowdown';

// 如果Node.js环境没有全局fetch,需要安装node-fetch并全局引入
// import fetch from 'node-fetch';
// (global as any).fetch = fetch;

const gd = new Glowdown({ 
  dataUrl: './times.json' // 纪念日数据文件路径
});

gd.init().then(() => {
  gd.applyStyle(); // 检查当前日期并应用样式
});

在浏览器中直接使用

  1. 引入脚本文件:
<script src="path/to/glowdown.browser.js"></script>
  1. 使用全局变量Glowdown:
const gd = new Glowdown({
  dates: [{
    name: "南京大屠杀纪念日",
    start: { y: -1, m: 12, d: 13, h: 0, min: 0 },
    end: { y: -1, m: 12, d: 13, h: 24, min: 59 }
  }]
});

gd.applyStyle();

自定义行为

const gd = new Glowdown({
  dates: [ // 直接传入纪念日数据,支持跨年纪念日
    {
      name: "跨年纪念日示例",
      start: { y: -1, m: 12, d: 31, h: 0, min: 0 },
      end: { y: -1, m: 1, d: 1, h: 23, min: 59 }
    }
  ],
  onMemorialDay: () => {
    // 这里必须自定义纪念日触发时的行为
    document.body.style.filter = 'grayscale(100%)';
    alert('今天是跨年纪念日');
  }
});

API 文档

Glowdown

构造函数

new Glowdown(options?: GlowdownOptions)

方法

  • init(): Promise<void> - 初始化并加载纪念日数据
  • checkDate(date?: Date): boolean - 检查指定日期是否是纪念日
  • applyStyle(): void - 应用纪念日样式

配置选项 (GlowdownOptions)

| 参数 | 类型 | 说明 | |------|------|------| | dataUrl | string | 可选,纪念日数据JSON文件的URL | | dates | MemorialDate[] | 可选,直接传入的纪念日数据数组 | | onMemorialDay | () => void | 可选,纪念日触发时的回调函数 |

MemorialDate 接口

interface MemorialDate {
  name: string; // 纪念日名称
  start: { // 开始时间
    y: number; // 年 (-1表示每年)
    m: number; // 月 (1-12)
    d: number; // 日 (1-31)
    h: number; // 时 (0-23)
    min: number; // 分 (0-59)
  };
  end: { // 结束时间
    y: number;
    m: number;
    d: number;
    h: number;
    min: number;
  };
}

纪念日数据格式

纪念日数据应为JSON数组,格式如下:

[
  {
    "name": "南京大屠杀纪念日",
    "start": {
      "y": -1,
      "m": 12,
      "d": 13,
      "h": 0,
      "min": 0
    },
    "end": {
      "y": -1,
      "m": 12,
      "d": 13,
      "h": 24,
      "min": 59
    }
  }
]

发布指南

1. 构建库文件

npm run build

这会生成:

  • Node.js版本:dist/src/glowdown.js
  • 浏览器版本:dist/glowdown.browser.js

2. 发布到npm

  1. 确保已登录npm账号:
npm login
  1. 发布包:
npm publish

3. 浏览器版本部署

  1. dist/glowdown.browser.js复制到你的静态文件目录
  2. 在HTML中通过script标签引入:
<script src="/path/to/glowdown.browser.js"></script>

许可证

MIT

TIPS: Don't forget the fucking repository & version key in your package.json file. --For other developers in this repository. /n --minc_nice_100 /n