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

ical-generator-lite

v1.0.0

Published

ical-generator-lite is a fork of ical-generator specifically for edge runtimes like Cloudflare Workers.

Downloads

137

Readme

ical-generator-lite is a fork of the ical-generator library specifically made for working on platforms like cloudflare workers. This package removes things like 'fs' and other unneeded things for edge-runtimes.

📦 Installation

npm install ical-generator-lite

# For TypeScript Users
# (see "I use Typescript and get TS2307: Cannot find module errors" section below)
npm i -D @types/node rrule moment-timezone moment dayjs @types/luxon

⚡️ Quick Start

import ical from "ical-generator-lite";
import http from "node:http";

const calendar = ical({ name: "my first iCal" });
const startTime = new Date();
const endTime = new Date();
endTime.setHours(startTime.getHours() + 1);
calendar.createEvent({
    start: startTime,
    end: endTime,
    summary: "Example Event",
    description: "It works ;)",
    location: "my room",
    url: "http://sebbo.net/",
});

http.createServer((req, res) => calendar.serve(res)).listen(
    3000,
    "127.0.0.1",
    () => {
        console.log("Server running at http://127.0.0.1:3000/");
    }
);

See the examples folder for more examples.

📑 API-Reference

🕒 Date, Time & Timezones

ical-generator-lite supports native Date, Day.js, Luxon's DateTime and the older moment.js and moment-timezone objects. You can also pass a string which is then passed to javascript's Date internally.

It is recommended to use UTC time as far as possible. ical-generator-lite will output all time information as UTC time as long as no time zone is defined. For day.js, a plugin is necessary for this, which is a prerequisite. If a time zone is set, ical-generator-lite assumes that the given time matches the time zone. If a time zone is used, it is also recommended to use a VTimezone generator. Such a function generates a VTimezone entry and returns it. For example, ical-timezones can be used for this:

import ical from "ical-generator-lite";
import { getVtimezoneComponent } from "@touch4it/ical-timezones";

const cal = new ICalCalendar();
cal.timezone({
    name: "FOO",
    generator: getVtimezoneComponent,
});
cal.createEvent({
    start: new Date(),
    timezone: "Europe/London",
});

If a moment-timezone object or Luxon's setZone method works, ical-generator-lite sets it according to the time zone set in the calendar/event.

🚦 Tests

npm test
npm run coverage
npm run browser-test

🙆🏼‍♂️ Credits

Original author Sebastian Pekarek