← 全部工具

cron-fast

热度 65 更新于 开发与构建

Fast and tiny JavaScript/TypeScript cron parser with timezone support - works in Node.js, Deno, Bun, Cloudflare Workers, and browsers. Zero dependencies.

npmauto-collected

安装

npm
npm install -g cron-fast

通过 npm 安装。

cron-fast

10x+ faster than the alternatives. 3.8KB gzipped. Zero dependencies.

Fast and tiny JavaScript/TypeScript cron parser with timezone support. Works everywhere: Node.js, Deno, Bun, Cloudflare Workers, and browsers.

Features

  • Parse & validate - Convert cron expressions to structured data and check validity
  • Get execution times - Calculate next, previous, or multiple scheduled runs
  • Match dates - Check if a date matches a cron expression
  • Describe - Convert cron expressions to human-readable text (e.g., "Every 5 minutes")
  • Timezone support - Full IANA timezone support using native Intl API
  • CLI included - Validate, preview, and describe expressions from the terminal

Why cron-fast?

  • 10x+ faster than other popular cron libraries on scheduling operations
  • ~8x smaller bundle than the next most popular alternative (see Bundle Size below)
  • Zero dependencies — nothing to audit, nothing to break
  • Universal runtime — same code in Node.js, Deno, Bun, Cloudflare Workers, and browsers
  • Tree-shakeable — import { isValid } adds < 1 KB to your bundle
  • TypeScript-first — strict types, no @ts-ignore required
  • Fully tested - Comprehensive test coverage across all runtimes
  • ISO 8601 compatible - Works with all standard date formats

Performance

cron-fast is designed for speed and efficiency. Here's how it compares to popular alternatives:

Tested with cron-fast v3.4.0, croner v10.0.1, cron-parser v5.6.1, cron-schedule v6.0.0 on Node.js v24.16.0

| Operation | cron-fast | cron-schedule | cron-parser | croner | | ------------- | --------------- | ------------- | ----------- | --------- | | Next run | 1179k ops/s | 331k ops/s | 36k ops/s | 31k ops/s | | Next 100 runs | 25k ops/s | 15k ops/s | 1k ops/s | 2k ops/s | | Previous run | 1296k ops/s | 346k ops/s | 39k ops/s | 31k ops/s | | Validation | 2912k ops/s | 454k ops/s | 95k ops/s | 34k ops/s | | Parsing | 2922k ops/s | 449k ops/s | 96k ops/s | 34k ops/s |

See detailed benchmarks (including Deno and Bun runtimes) for more information.

Run benchmarks yourself: pnpm bench

Installation

npm install cron-fast

pnpm add cron-fast

deno add jsr:@kbilkis/cron-fast

bun add cron-fast

# Any runtime (JSR)
npx jsr add @kbilkis/cron-fast

Quick Start

import { nextRun, previousRun, isValid, describe } from "cron-fast";

// Get next execution time (UTC)
const next = nextRun("0 9 * * *");
console.log(next); // Next 9:00 AM UTC

// With timezone
const nextNY = nextRun("0 9 * * *", { timezone: "America/New_York" });
console.log(nextNY); // Next 9:00 AM Eastern Time

// Get previous execution
const prev = previousRun("*/15 * * * *");