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

lunartick

v0.0.17

Published

[![npm version](https://badge.fury.io/js/lunartick.svg)](https://badge.fury.io/js/lunartick) [![Build Status](https://travis-ci.org/ordermentum/lunartick.svg?branch=master)](https://travis-ci.org/ordermentum/lunartick) [![npm](https://img.shields.io/npm/l

Downloads

1,540

Readme

Lunartick

npm version Build Status npm npm

Description

Based on the RFC5545 spec for Internet Calendaring and Scheduling Core Object Specification.

Lunartick!! ... get it!?

It's a pun on lunar and a crazy person, because that's what I feel like after working on this. It's a joke.

Anyway...

Lunartick allows you to parse an RRULE string to return an object of the properties in JS format. The returned object has an iterator() to either get the next run time based on a start time passed in (.getNext())or over the next X instances based on the RRULE COUNT or defaults to 1000 if no COUNT is present. If no start date is given, it will fetch the next run time based on the current time.

Please note that this package only supports ES6 friendly codebases.

Usage

NPM users

npm i lunartick

Yarn users

yarn add lunartick

Import the library and pass in an RRULE string to the .parse() method. The resulting instance supports the following properties: frequency, interval, count, bySetPos, byYearDay, byMonth, byMonthDay, byWeekNo, byEaster, byDay, byHour, byMinute, bySecond, tzId and dtStart.

const Rule = require('lunartick');
const rruleString = 'FREQ=DAILY;INTERVAL=1;BYHOUR=14;BYMINUTE=3;BYSECOND=0;DTSTART=19701101T020000';
const rule = Rule.parse(rruleString);
 /*{
   frequency: 2,
   interval: 1,
   byHour: [14],
   byMinute: [3],
   bySecond: [0],
   dtStart: '19701101T020000'
}*/

Once a string has been parsed, it can be converted back to an RRULE string using the .toString() method. This method does not take any parameters.

const string = rule.toString();
// 'FREQ=DAILY;INTERVAL=1;BYHOUR=14;BYMINUTE=3;BYSECOND=0;DTSTART=19701101T020000'

To fetch the next run time for this schedule call the .getNext() method with an optional from date, you can pass in the .dtStart property if you want to use it. If no from date is passed in, it will fetch the next run time base on the current time.

const nextRun = rule.getNext(rule.dtStart);
// Sun Nov 01 1970 14:03:00 GMT+1000

The rule instance will also have an iterator to fetch the next X runtimes for the rule. You can use a for-of loop on rule.iterator() which takes two optional parameters. The first one is the from date (default is also the current time). The second parameter is how many iterations should be fetched. If a number is passed in, it will take precedence, if a .count property exists in the rule, it will be used next and if neither are available it will default to 52 iterations.

const iterator = rule.iterator(rule.dtStart, 5);

for (const nextDate of iterator) {
  nextDate.toString();
}
// OR
Array.from(iterator);
/*
  Sun Nov 01 1970 14:03:00 GMT+1000
  Mon Nov 02 1970 14:03:00 GMT+1000
  Tue Nov 03 1970 14:03:00 GMT+1000
  Wed Nov 04 1970 14:03:00 GMT+1000
  Thu Nov 05 1970 14:03:00 GMT+1000
*/

Limitations

  • Currently does not support multiple values for byDay, byHour, byMinute and bySecond.

Licensing

Lunartick is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Originally developed by Michael Cooper - Development sponsored by Ordermentum.