The easiest way to schedule work items with complex dependencies across developers that all have different work schedules. Or reserve elevators in an apartment building. Or schedule the company ping pong tournament. Works in Node and in the browser.
View on GitHub Get Started// Define a set of tasks var tasks = [ {id: 1, duration: 60, available: later.parse.text('every weekday')}, {id: 2, duration: 30, dependsOn: [1], resources: ['A']}, {id: 3, duration: 30, dependsOn: [1], resources: [['A','B']]} ]; // Define a set of resources var resources = [ {id: A}, {id: B, available: later.parse.text('after 10:00am and before 6:00pm')} ]; // Create the schedule for all of the tasks schedule.create(tasks, resources);See a more complete, fully documented example of scheduling work items or reservations.
Schedule only depends on Later, a small library for working with recurring schedules. With no other dependencies using Schedule is easy.
Tasks, resources, and resulting schedules are simple json objects that are fully serializable. Easy to store in databases and in caches.
Tasks and resources support Later schedules to define when a task can be scheduled or a resource can be reserved.
Supported by a test suite of over 70 unit and scenario tests, additional tests for new scenarios always welcome.
All schedules are completely deterministic, meaning that they always produce the same set of results regardless of when you calculate them.
Schedule is available through both npm
and bower
.
After installing, Schedule is available in the schedule
namespace.
Using npm and Node.js:
$ npm install schedulejs
var schedule = require('schedulejs');
Using bower and a browser:
$ bower install later $ bower install schedule
<script src="later.min.js" type="text/javascript"></script> <script src="schedule.min.js" type="text/javascript"></script> <script type="text/javascript"> // schedule namespace is available </script>More information on building, running tests, and running benchmarks.
Tasks are the things that you want to schedule. You need to specify at least an id and a duration in minutes. You can then customize how the tasks get scheduled by:
Later
schedule that determines when the task is available
var tasks = [ {id: 1, duration: 60}, {id: 2, duration: 60, available: later.parse.text('every weekday')}, {id: 3, duration: 30, dependsOn: [1], priority: 100}, {id: 4, duration: 30, dependsOn: [1], minLength: 30}, {id: 5, duration: 90, dependsOn: [2,3]}, {id: 6, duration: 45, dependsOn: [4], resources: ['A']}, {id: 7, duration: 60, dependsOn: [5], resources: ['A', 'B']}, {id: 8, duration: 30, dependsOn: [6,7], resources: [['A', 'B'], 'C']} ];More information on tasks, task options and the task generator.
Resources are the things that your tasks require in order to be completed. By default, resources are automatically reserved when they are used by a task. Customize how the resources are used by:
Later
schedule that determines when the resources are available
var resources = [ {id: A}, {id: B, available: later.parse.text('after 10:00am and before 6:00pm')}, {id: C, isNotReservable: true} ];More information on resources, resource options and the resource generator.
Create a Later
schedule for the overall project, no tasks will be scheduled outside
of this schedule. Then decide when you want to start scheduling tasks from.
var projectAvailability = later.parse.text('every weekday'), startDate = new Date();
Finally pass your tasks, resources, project availability and start date to create
.
The return value is the schedule with start and end times for each task
that was successfully scheduled.
schedule.create(tasks, resources, projectAvailability, startDate);More information on creating schedules and understanding the results.