0.10.2 • Published 8 years ago

ics-js v0.10.2

Weekly downloads
3,088
License
ISC
Repository
github
Last release
8 years ago

ics-js

Create ICS files in ES6. Works in Node.js or in the browser.

NOTE: Please check out immutable-ics for a better JavaScript ICS solution.

Status

npm version Build Status js-standard-style

Installation

npm install --save ics-js

Documentation

Documentation

View documentation on ESDoc.

Quick Guide

Import the module:

import * as ICS from 'ics-js';

Or import just what is needed:

import { VCALENDAR, VEVENT } from 'ics-js';

Create a component

const cal = new ICS.VCALENDAR();

The following components are implenented:

  • VCALENDAR
  • VEVENT
  • VALARM
  • VTODO

Add properties to a component

/**
 * Component#addProp(name, value, props = {}, skipTransformer = false)
 *
 * @param {string} name - Name of the property (e.g. DTSTAMP).
 * @param {*} [value] - Value of the property.
 * @param {Object} [props={}] - Object of properties for the property. Object keys and values are directly injected.
 * @param {boolean} [skipTransformer=false] - Explicitly determine if the property's value is transformed.
 */

cal.addProp('VERSION', 2) // Number(2) is converted to '2.0'
cal.addProp('PRODID', 'XYZ Corp');

Each component contains a list of property validations. Only valid properties can be added according to the RFC 5545 spec.

The following properties are implemented:

NameInputOutput
CATEGORIESArray<String>Array items separated by ,
CREATEDDateFormatted date to spec
DTENDDateFormatted date to spec
DTSTAMPDateFormatted date to spec
DTSTARTDateFormatted date to spec
DUEDateFormatted date to spec
EXDATEArray<Date>Array items separated by , formatted to spec
GEOArray<Float>Array items separated by ; (should be [x, y])
LAST-MODIFIEDDateFormatted date to spec
RDATEDateFormatted date to spec
TRANSPBooleanTRANSPARENT if true, OPAQUE if false
UIDString or noneIf no input is provided, generates a random GUID
VERSIONNumberFloat with 1 decimal to spec

All other properties (e.g. SUMMARY, LOCATION) are stored as-is without transformations.

Nest a component

const event = new ICS.VEVENT();
event.addProp('UID');
event.addProp('DTSTAMP', new Date('2015-07-18 10:00:00'), { VALUE: 'DATE-TIME' });
event.addProp('ATTENDEE', null, {
  CN: 'Sample Company',
  RSVP: 'FALSE:mailto:foo@example.com'
})

cal.addComponent(event);

Each component contains a list of valid nested components. Only valid components can be nested according to the RFC 5545 spec.

Generate ICS data

cal.toString(); // Returns a string
cal.toBlob(); // Returns a Blob (or throws IncompatiblePlatform if Blob is undefined)
cal.toBase64(); // Returns a base64 encoded string
0.10.2

8 years ago

0.10.1

8 years ago

0.10.0

8 years ago

0.9.1

8 years ago

0.9.0

8 years ago

0.8.10

8 years ago

0.8.9

8 years ago

0.8.8

8 years ago

0.8.7

8 years ago

0.8.6

8 years ago

0.8.5

9 years ago

0.8.4

9 years ago

0.8.3

9 years ago

0.8.2

9 years ago

0.8.1

9 years ago

0.8.0

9 years ago

0.7.0

9 years ago

0.6.6

9 years ago

0.6.5

9 years ago

0.6.4

9 years ago

0.6.3

9 years ago

0.6.2

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.0

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago