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 🙏

© 2025 – Pkg Stats / Ryan Hefner

schedule-well

v1.1.0

Published

Node.JS calendar scheduling algorithm.

Readme

schedule-well

Node.JS calendar scheduling algorithm.

This library allows you to generate a set of scheduled events given a period to schedule over, a list of participants along with their weekly preferences and currently scheduled events, and a resolution.

The algorithm works by splitting up the input period into many subintervals according to the resolution parameter. Then the scheduled events and weekly preferences of participants for each event are taken into account. From there, a number of events will be scheduled that maximizes the weekly preferences of each participant.

Installation

The package exists on NPM. Use npm or yarn to retrieve the package and add it to your package.json.

npm install schedule-well --save

yarn add schedule-well

How to Use

scheduleEvents

The scheduleEvents function is the main export of the package. See tests for some example usage. The minimum usage is listed here for convenience.

import { scheduleEvents } from 'schedule-well';

const input = {
  resolution: { minutes: 30 },
  schedulingParameters: {
      schedulingPeriod: { start: "2019-06-30T00:00:00-0400", end: "2019-07-06T00:00:00-0400" },
      numberOfEvents: 5,
      lengthOfEvents: { hours: 1, minutes: 15 },
  },
  participants: [{
      id: 'one',
  }, {
      id: 'two'
  }, {
      id: 'three'
  }, {
      id: 'four'
  }]
}

const output = scheduleEvents(input);

scheduleEvents input

schedule-well uses the Luxon datetime library internally to handle its datetimes, intervals, durations, and timezones.

https://www.npmjs.com/package/luxon

One feature of the library is that you can use plain javascript objects in many places where Luxon objects are expected. This will allow the library to be used without having to explicitly import luxon into your package.

DurationLike accepts a Luxon Duration, a duration object, an ISO string for periods, or a number of milliseconds.

DateTimeLike accepts a Luxon datetime, a javascript date, an ISO string for datetimes, or a number of milliseconds since Jan 1, 1970.

IntervalLike accepts a Luxon interval, or an object { start: DateTimeLike, end: DateTimeLike }

Input formats:

{
    resolution: DurationLike,
    participants: {
        id: string|symbol,
        weeklyPreferences: {
            weight: number,
            interval: IntervalLike
        }[]
    }[].
    schedulingParameters: {
        schedulingInterval: IntervalLike,
        ambientWeeklyPreferences: {
            weight: number,
            interval: IntervalLike
        }[],
        eventsToSchedule: {
            participantIds: (string|symbol)[]
            eventDuration: DurationLike
        }[],
    }
}

or

{
    resolution: DurationLike,
    participants: {
        id: string|symbol,
        weeklyPreferences: {
            weight: number,
            interval: IntervalLike
        }[]
    }[].
    schedulingParameters: {
        schedulingInterval: IntervalLike,
        ambientWeeklyPreferences: {
            weight: number,
            interval: IntervalLike
        }[],
        numberOfEvents: number,
        lengthOfEvents: DurationLike | DurationLike[]
    }
}

Output:

{
    participantIds: (string|symbol)[];
    eventInterval: {
        start: DateTime, //Luxon datetimes
        end: DateTime
    };
}[]

Refer to typescript types for more detailed information about what can be provided.