Getting started

Overview of how to work with the Later project.

Installation

Later is available through both npm and bower for easy installation. The installation includes all of the files that you will need to use the library. Node.js is required for building, testing, and benchmarking the library.


Using npm:

  $ npm install later

Using bower:

  $ bower install later

If you would prefer, you can also download the source along with compiled versions of the library in a single zip file. Note that you will need to have Node.js and NPM installed in order to make builds, run tests, or run benchmarks.

Download

Example usage

Later works in both the browser (IE7+, FireFox, Chrome, Safari) and Node.js environments. Simply include the library to get access to the Later namespace and all functionality.


Node Example

  var later = require('later');

  var sched = later.parse.text('every 5 mins'),
      occurrences = later.schedule(sched).next(10);

  for(var i = 0; i < 10; i++) {
    console.log(occurrences[i]);
  }

Browser Example

  <script src="later.min.js" type="text/javascript"></script>
  <script type="text/javascript">

  var sched = later.parse.text('every 5 minutes'),
      occurrences = later.schedule(sched).next(10);


  for(var i = 0, i < 10; i++) {
    console.log(occurrences[i]);
  }

  </script>

Building

To build the development and production (minified) versions of Later, first make sure that you have installed all of the dependencies. Later uses smash to first combine the source files and then uglify to minify it for production.

  $ make all

If you are not using the Cron or English text parsers, you can significantly reduce the library file size by excluding these from the build. To do so, modify /src/parse/index.js and remove the parsers that you are not using. Keep in mind that the text parser has a dependency on the recur parser.

Once you're done modifying the file, simple run make all.

Running tests

Later includes over 40,000 unit and scenario tests that currently cover over 97% of the codebase. The suite takes approximately 20 seconds to run on modern hardware. Later uses mocha for testing which must be installed prior to running tests.

  $ make test

Benchmarks

There are some basic benchmarks (using benchmarkjs) included in the installation that test the performance of the various time periods and a basic and complex schedule. The benchmarks will provide you with an idea of how the library will perform on your hardware.

  $ make benchmark

License

The MIT License (MIT)

Copyright © 2013 BunKat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.