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

jurassic

v0.11.5

Published

A javascript library for manipulating periods.

Downloads

13

Readme

Build Status

jurassic

A javascript library for periods manipulations.

The library contain 2 base objects to handle periods:

  • jurassic.Era: a group of periods
  • jurassic.Period: a period with a start date and end date

The library has been tested only on node.js

Usage

npm install jurassic

Methods

Era.addPeriod

Add a period to Era, accept a period object as parameter, if the given parameter is not a period, the period will be created from the object


var jurassic = require('jurassic');
var era = new jurassic.Era();

var event1 = new jurassic.Period();
event1.dtstart = new Date(2014,0,1);
event1.dtend = new Date(2014,0,3);

era.addPeriod(event1);

era.addPeriod({
    dtstart: new Date(2014,0,6),
    dtend: new Date(2014,0,8)
});

The period can contain other properties such as icalendar properties

Era.removePeriod

Remove a periods from era using dates only, if a period with the same dates exists in era, il will be removed. Accept a period object as parameter

Era.getFlattenedEra

Get a new era with all overlapping periods merged as single periods

Era.addEra

Returns a new Era object whose value is the sum of the specified Era object and this instance.

Era.subtractPeriod

Update the Era object with the difference between the specified Period object and this instance. Accept a period object as parameter


var jurassic = require('jurassic');
var era = new jurassic.Era();

era.addPeriod({
    dtstart: new Date(2014,0,1),
    dtend: new Date(2014,0,15)
});

var drill = new jurassic.Period();
drill.dtstart = new Date(2014,0,10);
drill.dtend = new Date(2014,0,11);

era.subtractPeriod(drill);

// here we have 2 periods, from 1 to 10 and from 11 to 15

Era.subtractEra

Update the Era object with the difference between the specified Era object and this instance.

Era.intersectPeriod

Get the intesection of the era with a period. Accept a period object as parameter. This method return an Era object (a list of periods) the properties from the periods stored in the era object will be retained in the new periods produced by this method.

Era.intersectEra

Get the intesection of the specified Era object and this instance. This method return an Era object (a list of periods)

Period

A period can contain any property, only dtstart and dtend are mandatory for the interaction with the library methods.

Period.getBusinessDays

get the number of days in period with a precision of 0.5 days