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

@usefulish/smartcron

v0.1.5

Published

Declarative and safe cron decorator for NestJS with UTC offset support.

Readme

@usefulish/smartcron

npm version npm downloads License

A lightweight, declarative cron decorator for NestJS with runtime validation, safe intervals, and built-in UTC offset support.


Installation

npm install @usefulish/smartcron

or

yarn add @usefulish/smartcron

Usage

import { SmartCron } from '@usefulish/smartcron';

@SmartCron({
  intervalInMinutes: 13,
  fromHour: 8,
  toHour: 17,
  fromMinute: 5,
  toMinute: 50,
  weekdaysOnly: true,
  timezone: -3,
})
handleJob() {
  // Runs every 13 minutes from 08:05 to 17:50, Monday to Friday, in UTC-3
}

Available Options

| Option | Type | Required | Default | Description | | ------------------- | ---------------- | -------- | ------- | -------------------------------------------------------------------------------------- | | intervalInMinutes | AllowedMinutes | ✅ | — | Interval in minutes. Must be one of the allowed values. | | fromHour | Hour | ❌ | 0 | Start hour (inclusive). | | toHour | Hour | ❌ | 23 | End hour (inclusive). If lower than fromHour, range is treated as crossing midnight. | | fromMinute | Minute | ❌ | 0 | Start minute (inclusive). Only applies to the first hour of the range. | | toMinute | Minute | ❌ | 59 | End minute (inclusive). Only applies to the last hour of the range. | | weekdaysOnly | boolean | ❌ | false | Limits execution to weekdays (Mon–Fri) if true. | | timezone | UTCOffset | ❌ | 0 | UTC offset (e.g., -3 for UTC-3). Affects CRON scheduling context. |


Allowed Intervals

The following minute intervals are supported:

[7, 11, 13, 17, 19, 23, 29, 31, 37, 41];

These are intentionally non-standard (mostly primes) to minimize cron collision in shared environments.


Timezone Support

You can configure the execution timezone using a UTC offset:

  • Positive values (e.g., 3) represent UTC+3
  • Negative values (e.g., -5) represent UTC-5
  • Default is 0 (UTC)

Internally, the offset is converted to an IANA-compatible timezone (e.g., Etc/GMT+3 for UTC-3).


Type Exports

This package also exports the following types for use in your codebase:

import {
  SmartCronOptions,
  AllowedMinutes,
  Hour,
  Minute,
  UTCOffset,
} from '@usefulish/smartcron';

License

MIT