Skip to content

Swydo/simple-recur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-recur

Build status

Calculate date recurrence. A great alternative to moment-recur and later.

Install

npm install simple-recur

Options

  • units (Number)
  • measure ('weeks', 'months', 'years')
  • start (Date)
  • from (Date)

Examples

JavaScript:

const Recur = require('simple-recur');
const recur = new Recur(options);

// check if a given date matches this recurrence
const matches = recur.matches(new Date());
console.log('matches', matches);
// outputs: true/false

// get the next 3 occurrences
const nextThreeOccurrences = recur.next(3);
console.log('nextThreeOccurrences', nextThreeOccurrences);
// outputs: [moment, moment, moment]

CoffeeScript:

Recur = require 'simple-recur'

recur = new Recur
recur.every 2, 'month'

recur.next 3
# outputs: [moment, moment, moment]

recur.matches new Date
# outputs a boolean

Test

npm test

Build

npm run build

Watch

npm run watch

Releases

No releases published

Packages

No packages published