1.6.2 • Published 8 months ago

ts-ics v1.6.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

TS-ICS

neuvernetzung-logo

NPM

This package can parse and create Ics files and provides TypeScript types for easy handling.

Motivation

Many of the Ics packages provide good functionality, however none of these are type safe. This package can parse Ics strings with Zod. Also, many packages are not actively maintained.

Installation

npm i ts-ics

generate

generateIcsCalendar

import { generateIcsCalendar, type VCalendar } from "ts-ics";

const calendar: VCalendar = {...}

const icsCalendarString = generateIcsCalendar(calendar);

generateIcsEvent

import { generateIcsEvent, type VEvent } from "ts-ics";

const event: VEvent = {...}

const icsEventString = generateIcsEvent(event);

parse

parseIcsCalendar

parse with zod

import { parseIcsCalendar, type VCalendar } from "ts-ics";

const calendarParsed: VCalendar = parseIcsCalendar(icsCalendarString);

without zod parsing

import { icsCalendarToObject, type VCalendar } from "ts-ics";

const calendar: VCalendar = icsCalendarToObject(icsCalendarString);

parseIcsEvent

parse with zod

import { parseIcsEvent, type VEvent } from "ts-ics";

const eventParsed: VEvent = parseIcsEvent(icsEventString);

without zod parsing

import { icsEventToObject, type VEvent } from "ts-ics";

const event: VEvent = icsEventToObject(icsEventString);

utils

extendByRecurrenceRule

import { extendByRecurrenceRule } from "ts-ics";

const start = new Date(Date.UTC(2023, 9, 5));
const ruleString = "FREQ=DAILY;BYMINUTE=15,16,17,18,19;BYSECOND=0,20,40";

const rule = parseIcsRecurrenceRule(ruleString);

const dates = extendByRecurrenceRule(rule, {
  start,
  end: addDays(start, 1),
});

License

MIT - License

Thanks

Thanks to iCalendar.org for the ics documentation and the many examples which are used for testing purposes.

1.6.2

8 months ago

1.6.1

9 months ago

1.6.0

9 months ago

1.5.0

10 months ago

1.4.2

11 months ago

1.4.1

12 months ago

1.4.0

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.12

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago