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

@minisss/cron

v0.0.1-alpha.7

Published

crontab 语法 JavaScript 定时任务执行库

Readme

cron

crontab 语法 JavaScript 定时任务执行库

  • 🤡 支持广泛浏览器
  • 🤡 无依赖包
  • ✅ 新增 x#* 语法 当月每周星期x支持(写法: 2#* 当月每周星期2)
  • ✅ 支持秒级

安装方式

# pnpm
pnpm i @minisss/cron

# yarn
yarn add @minisss/cron

# npm
npm i @minisss/cron

# bun
bun install @minisss/cron

使用方式

cron 语法

 # ┌────────────── second (可选)
 # │ ┌──────────── minute
 # │ │ ┌────────── hour
 # │ │ │ ┌──────── day of month
 # │ │ │ │ ┌────── month
 # │ │ │ │ │ ┌──── day of week
 # │ │ │ │ │ │
 # │ │ │ │ │ │
 # * * * * * *

cron 时间字段

| 字段 | 描述 | 取值 | 特殊字符 | | ------ | ---------------------- | ---- | --------------- | | week | 星期几(0或7代表星期天) | 0-7 | * , - / ? L # | | month | 月份 | 1-12 | * , - / | | day | 日期(日/每月第几天) | 1-31 | * , - / ? L W | | hour | 小时 | 0-23 | * , - / | | minute | 分钟 | 0-59 | * , - / | | second | 秒数(可选) | 0-59 | * , - / |

cron 特殊字符

  • *:表示当前字段域所有取值
  • ,:指定多个值,例如 1,3,5 表示第 1、3、5 个值。
  • -:指定范围,例如 1-5 表示第 1 到第 5 个值。
  • /:指定步长,例如 */5 表示每 5 个值。
  • ?:表示不指定,用于日期和星期字段。
  • L:表示最后一个,例如 day L 每月的最后一天,week xL 表示每月的最后一个星期x。
  • W:表示工作日。例如 xW代表x日最近的工作日。 LW代表最后一个工作日。
  • #:表示指定星期几,例如 1#3 表示第三个星期一, 1#* 表示当月每周星期1。

API

| 方法 | 描述 | 参数 | 返回值 | | ---- | ---------------- | ------------------------------- | ------ | | add | 添加一个定时任务 | add(cronExpression, task, conf) | ITask |

ITask

| 方法 | 描述 | 参数 | 返回值 | | ---- | ------------ | ------ | ----------------- | | stop | 停止定时任务 | stop() | 当前任务实例 this |

CONF配置项

| 参数 | 描述 | 类型 | 默认值 | | ------------ | -------------------- | ------- | ------ | | isDayWeekAnd | 日期与周 逻辑与 关系 | boolean | false |