Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ical.js

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ical.js

Javascript parser for ics (rfc5545) and vcard (rfc6350) data

  • 1.5.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is ical.js?

ical.js is a JavaScript library for parsing and manipulating iCalendar data. It allows you to create, parse, and manipulate iCalendar files, which are commonly used for calendar events and scheduling.

What are ical.js's main functionalities?

Parsing iCalendar Data

This feature allows you to parse iCalendar data from a string and extract information from it. In this example, we parse an iCalendar string and extract the summary of the first event.

const ICAL = require('ical.js');
const icalData = 'BEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nSUMMARY:Test Event\nDTSTART:20230301T120000Z\nDTEND:20230301T130000Z\nEND:VEVENT\nEND:VCALENDAR';
const jcalData = ICAL.parse(icalData);
const comp = new ICAL.Component(jcalData);
const vevent = comp.getFirstSubcomponent('vevent');
const summary = vevent.getFirstPropertyValue('summary');
console.log(summary); // Output: Test Event

Creating iCalendar Data

This feature allows you to create iCalendar data programmatically. In this example, we create a new event with a summary, start time, and end time, and then convert it to an iCalendar string.

const ICAL = require('ical.js');
const event = new ICAL.Component(['vcalendar', [], [
  ['vevent', [], [
    ['summary', {}, 'text', 'New Event'],
    ['dtstart', {}, 'date-time', '20230301T120000Z'],
    ['dtend', {}, 'date-time', '20230301T130000Z']
  ]]
]]);
const icalString = event.toString();
console.log(icalString);

Manipulating iCalendar Data

This feature allows you to manipulate existing iCalendar data. In this example, we parse an iCalendar string, update the summary of the first event, and then convert it back to an iCalendar string.

const ICAL = require('ical.js');
const icalData = 'BEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nSUMMARY:Test Event\nDTSTART:20230301T120000Z\nDTEND:20230301T130000Z\nEND:VEVENT\nEND:VCALENDAR';
const jcalData = ICAL.parse(icalData);
const comp = new ICAL.Component(jcalData);
const vevent = comp.getFirstSubcomponent('vevent');
vevent.updatePropertyWithValue('summary', 'Updated Event');
const updatedIcalString = comp.toString();
console.log(updatedIcalString);

Other packages similar to ical.js

Keywords

FAQs

Package last updated on 06 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc