The node-timeline module is tiny timeline event scheduler in pure JavaScript for node.js inspired by node-cron. This module allows you to schedule timeline events in node.js.
- Support event insertion into random places in the timeline. ie After the event labeled 'sunset'
Install node-timeline using npm:
$ npm install --save delos/node-timeline#master
Import node-timeline and schedule a task:
const Timeline = require('node-timeline');
This is a quick reference to timeline event syntax and also shows the options supported by node-timeline.
type | value | Description |
---|---|---|
number | posiive number | Absolute time from timeline starting time. |
string | '+[number]' | Relative time from previous event firing time. |
Timelines can be run at 'real' time or at a different time scale. Default value is 1. Setting the timescale to 2 would run the timeline twice as fast. 0.5 twice as slow. 4 would run at 4x.
Arguments:
- number
number
: Timescale
Example:
const {Timeline, TimelineEvent} = require('node-timeline');
const name = 'Timescale test';
const timeline = new Timeline({name});
function hello() {console.log("Hi!")}
const event = new TimelineEvent({label: 'e1', startTime: 10, func: hello})
timeline.add(event);
timeline.play(); // displays Hi! after 10 seconds
timeline.setTimescale(2);
timeline.play(); // displays Hi! after 5 seconds
// example
Feel free to submit issues and enhancement requests here.
In general, we follow the "fork-and-pull" Git workflow.
- Fork the repo on GitHub;
- Commit changes to a branch in your fork;
- Pull request "upstream" with your changes;
NOTE: Be sure to merge the latest from "upstream" before making a pull request!
Please do not contribute code you did not write yourself, unless you are certain you have the legal ability to do so. Also ensure all contributed code can be distributed under the ISC License.
This project exists thanks to all the people who contribute.
node-cron is under ISC License.