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 🙏

© 2024 – Pkg Stats / Ryan Hefner

timelyjs

v0.0.1

Published

Javascript schedules and calendars

Downloads

1

Readme

timely Build Status

A simple module for schedules and calendars in Javascript

Getting Started

Install the module with: npm install timely

var Timely = require('timely')
  , cal = new Timely();

Overview

Timely is a simple way to represent basic chronological events in Javascript. It is useful for storing scheduling information in a Javascript object, while providing validation and utility methods to adhere to scheduling rules.

Each instances of timely is an object consisting of properties events, settings, and schedules

events is an array of objects representing events. Each object is an event with the following keys:

  • uuid - unique identifier of event (set automatically)
  • name - name of the event (String, required)
  • description - description of the event (anything, optional)
  • start - Date (and time) of start (required)
  • stop - Date (and time) of stop (required)
  • schedules - Array of the schedules this event includes (elements are String)
  • avoid_events - Array of events that MUST NOT overlap with this event (elements can be RegExp, used to match against event names, or String used to match event names or uuids)
  • require_events - Array of events that MUST overlap with this event (elements can be RegExp, used to match against event names, or String used to match event names or uuids)
  • avoid_schedules - Array of schedules that MUST NOT have events that overlap with this event (elements can be RegExp, used to match against schedule names, or String used to match schedule names or uuids)
  • require_schedules - Array of schedules that MUST have events that overlap with this event (elements can be RegExp, used to match against schedule names, or String used to match schedule names or uuids)
  • precede_events - Array of events that MUST follow this event (elements are Object with keys event - String or RegExp of the event, and key required - Boolean, if true event must actually follow event, if false event must only follow event if it occurs)

schedules is an array of the schedules included in events. Schedules represent categories of events, which might further represent personnel schedules, resource calendars, a series of events, etc. Each schedule is an Object which includes the following keys:

  • name - name for schedule - must be unique
  • description - additional information / metadata for the schedule

In addition, the schedule named * is reserved to represent the schedule of all events. It serves as a way to reference all events as a collective group.

settings is an object of options for the instances. It can include:

  • start - Date (and time) of calendar start. No events may precede this if set.
  • stop - Date (and time) of calendar stop. No events may follow this if set.

Methods

Timely provides methods to manage and validate the schedules and events it represents

  • addEvent(event, options) - Add an event. If times are omitted, method tries to find a suitable time that fits a duration option. If no suitable time can be found, an error is returned. If the event already exists (i.e. a passed uuid matches a current event) the existing event is updated and validated. If invalid and flexible is passed as an option, a suitable time is sought. If it is found, the event is moved, it not an error is returned.
  • removeEvent(event, options) - Removes an event from the schedule. Optionally scoped by schedule
  • validate() - Validates all events
  • validateSchedules(schedules) - Validate all events in passed schedules
  • validateEvents(events) - Validate a specific event
  • findTime(event, options) - Find a valid time for an event
  • getSchedule(schedules, options) - Return events for a schedule or group of schedules. Optionally scoped by start and stop and union (return group of events shared by all passed schedules)

License

Copyright (c) 2014 Ben Sack Licensed under the MIT license.