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
Installation
npm install --save ics-js
Documentation
Quick Guide
Import the module:
;
Or import just what is needed:
;
Create a component
const cal = ;
The following components are implenented:
VCALENDAR
VEVENT
VALARM
VTODO
Add properties to a component
/** * Component#addProp(name, value, props = {}, skipTransformer = false) * * @param * @param * @param * @param */ cal // Number(2) is converted to '2.0'cal;
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:
Name | Input | Output |
---|---|---|
CATEGORIES |
Array<String> |
Array items separated by , |
CREATED |
Date |
Formatted date to spec |
DTEND |
Date |
Formatted date to spec |
DTSTAMP |
Date |
Formatted date to spec |
DTSTART |
Date |
Formatted date to spec |
DUE |
Date |
Formatted date to spec |
EXDATE |
Array<Date> |
Array items separated by , formatted to spec |
GEO |
Array<Float> |
Array items separated by ; (should be [x, y] ) |
LAST-MODIFIED |
Date |
Formatted date to spec |
RDATE |
Date |
Formatted date to spec |
TRANSP |
Boolean |
TRANSPARENT if true, OPAQUE if false |
UID |
String or none |
If no input is provided, generates a random GUID |
VERSION |
Number |
Float with 1 decimal to spec |
All other properties (e.g. SUMMARY
, LOCATION
) are stored as-is without
transformations.
Nest a component
const event = ;event;event;event cal;
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; // Returns a stringcal; // Returns a Blob (or throws IncompatiblePlatform if Blob is undefined)cal; // Returns a base64 encoded string