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

scrapegoat

v2.0.0

Published

fetches calendar/event objects from a CalDav server

Downloads

795

Readme

scrapegoat

Build Status Dependency Status

This library requests a calendar object and its events provided by a CalDav server.

Specify basic configuration:

config = {
    auth: {
        user: "username",
        pass: "password"
    },
    // example using baikal as CalDAV server
    uri: "http://example.com/cal.php/calendars/<user name>/<calendar name>"
};

The request will timeout if it gets no reponse from the CalDav server after 10 seconds. An optional timeout parameter can be provided to override this default by passing an integer containing the number of milliseconds to wait for the server to send the response before aborting the request.

config = {
    auth: {
        user: "username",
        pass: "password"
    },
    uri: "http://example.com/cal.php/calendars/<user name>/<calendar name>",
    timeout: 20000
};

API

scrapegoat.getCtag()

Fetches the ctag of a calendar. You can use the calendar's ctag to see if anything in the calendar has changed.

const Scrapegoat = require("scrapegoat");

const scrapegoat = new Scrapegoat(config);

scrapegoat.getCtag().then(console.log);

You'll get an object, which looks like this:

{
   href: '/cal.php/calendars/test/holidays/',
   name: 'Holiday',
   ctag: '452'
}

scrapegoat.getEtags()

Fetches the etags of all events. You can use the events etags to see if an event has changed.

scrapegoat.getEtags().then(console.log);

You'll get an array of objects, which looks like this:

[
    {
        ics: "/cal.php/calendars/test/holidays/6151613161614616.ics",
        etag: "fc46dd304e83f572688c68ab63816c8f"
    },
    {
        ics: "/cal.php/calendars/test/holidays/6816189165131651.ics",
        etag: "8d59671ba294af1de0e0b154a8ea64c2"
    }
];

scrapegoat.getEvents(events)

Fetches events with its data/details. events has to be an array with objects, which contain an ics attribute. The ics attribute has to look like the ones we get with getEtags().

const events = [
  { ics: '/cal.php/calendars/user/calendar_name/12345.ics' }
  { ics: '/cal.php/calendars/user/calendar_name/67890.ics' }
];

scrapegoat.getEvents(events).then(console.log);

Output should be something like this:

[
    {
        ics: "/cal.php/calendars/test/holidays/1234564316516.ics",
        etag: "fc46dd304e83f572688c68ab63816c8f",
        data: {
            title: "Holiday: John Doe",
            uid: "56ea42c0-e4af-4ac8-8d60-d95996c9ddc5",
            location: "Kissing, Augsburg, Germany",
            description: null,
            start: "2017-02-16T00:00:00.000Z",
            end: "2017-02-18T00:00:00.000Z",
            duration: {
                weeks: 0,
                days: 2,
                hours: 0,
                minutes: 0,
                seconds: 0,
                isNegative: false
            },
            type: { recurring: false, edited: false },
            createdAt: "2017-01-24T15:33:04.000Z"
        }
    }
];

scrapegoat.getAllEvents()

Fetches all events of the given calendar with data/details.

scrapegoat.getEventsByTime(start, end)

Fetch all events which occur between start and end (have to be valid iCal Dates). If you leave start and end out, you'll get all upcoming events from today. Passing only one date as a parameter returns all upcoming events from that date. The end-date must be larger that the start-date.

Example using moment.js for date formatting:

const moment = require("moment");

const start = moment()
    .startOf("month")
    .format("YYYYMMDD[T]HHmmss[Z]");
const end = moment()
    .endOf("month")
    .format("YYYYMMDD[T]HHmmss[Z]");

scrapegoat.getEventsByTime(start, end).then(console.log);

The example below gets all events happening on a single day

const moment = require("moment");

const start = moment("20170216T0000").format("YYYYMMDD[T]HHmmss[Z]");
const end = moment("20170216T2300").format("YYYYMMDD[T]HHmmss[Z]");

scrapegoat.getEventsByTime(start, end).then(console.log);

Sponsors