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

@bemedev/scheduler

v1.2.1

Published

A cancellable interval and timer library for JavaScript and TypeScript.

Readme

@bemedev/scheduler

A flexible scheduler for managing and executing tasks with advanced timing and state management capabilities.

Installation

pnpm add @bemedev/scheduler

Usage

Async Scheduler (default)

import { createScheduler } from '@bemedev/scheduler';

const scheduler = createScheduler();

// Initialize the scheduler (optionally with an initial task)
scheduler.start();

// Schedule a synchronous task
scheduler.schedule(() => {
  console.log('Task executed');
});

// Schedule an asynchronous task
scheduler.schedule(async () => {
  await fetch('/api/data');
});

// Schedule with immediate execution (bypasses the queue)
scheduler.schedule(() => console.log('Immediate!'), true);

// Pause task execution
scheduler.pause();

// Schedule tasks while paused (they remain queued)
scheduler.schedule(() => console.log('Queued task'));

// Resume task execution (processes queued tasks asynchronously)
await scheduler.resume();

// Stop the scheduler (cancels pending async tasks)
scheduler.stop();

// Check scheduler state
console.log(scheduler.performeds); // number of tasks executed
console.log(scheduler.state); // current state

Synchronous Scheduler

import { createSyncScheduler } from '@bemedev/scheduler/sync';

const scheduler = createSyncScheduler();

// Initialize the scheduler
scheduler.start();

// Schedule a synchronous task
scheduler.schedule(() => {
  console.log('Task executed');
});

// Pause task execution
scheduler.pause();

// Schedule tasks while paused
scheduler.schedule(() => console.log('Queued task'));

// Resume task execution synchronously (executes queued tasks immediately)
scheduler.resume();

// Stop the scheduler
scheduler.stop();

API

Main Export (Async Scheduler)

Creates and returns a new AsyncScheduler instance via createScheduler() (or createAsyncScheduler()).

scheduler.start(callback?)

Initializes the scheduler. Optionally executes an initial task immediately. No-op if already started. Returns this.

scheduler.schedule(callback, immediate?)

Schedules a task for execution.

| Parameter | Type | Default | Description | | ----------- | --------------------------- | ------- | --------------------------------------------------------------------- | | callback | () => any \| Promise<any> | — | The task to execute | | immediate | boolean | false | If true, bypasses the queue and runs immediately with abort support |

scheduler.pause()

Pauses task execution. Saves the current state and sets scheduler.state to 'paused'. Tasks scheduled while paused are queued without being processed until resume() is called. Returns the updated state 'paused'.

scheduler.resume()

Resumes task execution:

  • Async Scheduler: await scheduler.resume() restores state and asynchronously processes the next queued task. Returns a Promise<State>.
  • Sync Scheduler: scheduler.resume() restores state and synchronously processes all queued tasks. Returns State.

scheduler.stop()

Stops the scheduler and cancels any in-flight async tasks via AbortController. Returns the final state 'stopped'.

scheduler.state

Read-only. Current state of the scheduler:

| Value | Description | | -------------- | -------------------------- | | 'available' | Ready to process tasks | | 'processing' | Currently executing a task | | 'paused' | Paused; tasks are queued | | 'stopped' | Permanently stopped |

scheduler.isPaused

Read-only. Returns true if scheduler.state is 'paused' or 'stopped', false otherwise.

scheduler.notAvailable

Read-only. Returns true if scheduler.state is not 'available', false otherwise.

scheduler.performeds

Read-only. Number of tasks successfully executed.

Synchronous Scheduler Export (./sync)

Access via import { createSyncScheduler, createScheduler } from '@bemedev/scheduler/sync'.

The createSyncScheduler() (or createScheduler()) factory function creates a synchronous scheduler instance that provides the same interface as the async scheduler, but executes tasks synchronously without Promise support.

Async Scheduler Export (./async)

Access via import { createAsyncScheduler, createScheduler } from '@bemedev/scheduler/async' (equivalent to the default export from @bemedev/scheduler).

Licence

MIT

CHANGE_LOG

[0.0.1] - 09/03/2026 => 03:36

  • Add Scheduler class with full lifecycle management
  • Add createScheduler() factory function
  • Add start, schedule, stop methods
  • Add async task support with AbortController
  • Test coverage 100%

Auteur

chlbri ([email protected])

My github

Liens