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

nschedule

v0.4.0

Published

Task scheduler with concurrency limits.

Readme

NSchedule

An efficient periodic task scheduler with concurrency limits.

Features

  • Limits the nunmber of concurrently executing tasks. This avoids overloading the resource used by the task (a server or network link, for example).
  • Efficiently schedules tasks that must be repeated periodically.
  • Individual tasks are rescheduled after they have run. This prevents multiple invocations of the same task from overlapping.
  • Allows any combination of: immediate/delayed and periodic/one-shot.

Related Packages

Some other packages you might want to consider.

  • agenda Database-backed cron-like scheduler.
  • flagpoll Supports a finite number of task executions (will not reschedule a task indefinitely).
  • node-schedule Cron-like scheduling. From the readme: 'node-schedule is for time-based scheduling, not interval-based scheduling.'
  • poll Work in progress.
  • pomelo-schedule Allows cron syntax. No concurrency limits. For example, schedule 100 tasks with different intervals in the same section of code and all 100 will trigger immediately.
  • simple-schedule All tasks must have the same interval and do not recur.

Installation

npm install nschedule

Common Usage


    #! /usr/bin/env node

    // ---------------------------------------------------------------------------
    // Demonstrates some common scheduling frequency and recurrence patterns.
    // ---------------------------------------------------------------------------

    var Scheduler = require('nschedule');

    // Create a scheduler that will not execute more than 2 tasks
    // at a time.
    var scheduler = new Scheduler(2);

    // This task recurs every 3 seconds.
    scheduler.add(3000, function(done){
        console.log("Task at period  3s. " + (new Date).toISOString());
        done();
    });

    // This task recurs every 5 seconds.
    scheduler.add(5000, function(done){
        console.log("Task at period  5s. " + (new Date).toISOString());
        done();
    });

    // This task executes once after 15 seconds.
    scheduler.add(15000, function(done){
        console.log("Task at period 15s. " + (new Date).toISOString());
        done(scheduler.STOP);
    });

    // This task executes immediately and does not recur.
    // The interval is effectively ignored.
    scheduler.add(1000, function(done){
            console.log("One shot task.      " + (new Date).toISOString());

            // Stop after first and only execution.
            done(scheduler.STOP);
        },
        scheduler.IMMEDIATE);

Concurrency Limiting Example


    #! /usr/bin/env node

    // ---------------------------------------------------------------------------
    // Demonstrates the limit on concurrently executing tasks.
    // ---------------------------------------------------------------------------

    var Scheduler = require('nschedule');

    var TICK_IN_MS = 100;

    // Create a scheduler that will not execute more than 1 task
    // at a time.
    var scheduler = new Scheduler(1);

    // This task recurs every second but will be blocked for executing by the long
    // running task schedule every 5s.
    scheduler.add(1000, function(done){
        logWithTimestamp('Task at 1s  *');
        done();
    });

    // This task is scheduled to recur every 5s but also takes 5s to execute, so it
    // will actually execute every 10s.
    //
    // As the scheduler was created with a concurrency setting of 1, when this task
    // executes it will block the task that runs every 1s while it is executing.
    // To prevent this behavior, create the scheduler with a higher concurrency
    // setting.
    scheduler.add(5000, function(done){
        logWithTimestamp('Task at 10s  ********** (start)');
        busy('Task at 10s  ********** (end)', 5000, done);
    });

    // Simulate some operation that takes time to complete (backing up a database or
    // network communications, for exanple).
    function busy(name, interval, done){
        if(interval <= 0){
            logWithTimestamp(name);
            done();
            return;
        }

        setTimeout(function(){
            busy(name, interval - TICK_IN_MS, done);
        }, TICK_IN_MS);
    }

    function logWithTimestamp(name){
        console.log((new Date).toISOString() + " " + name);   
    }