or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

component-parser.mdcomponents.mddesign-system.mdduration.mdevents.mdhelpers.mdindex.mdparsing.mdperiod-binary.mdproperties.mdrecurrence.mdtime.mdtimezone.mdvcard-time.md
tile.json

properties.mddocs/

Property Management

Detailed property manipulation including parameters, multi-values, and type-specific value handling. The Property class provides a layer on top of raw jCal property data for manipulating individual properties with their parameters and values.

Capabilities

Property Class

Wraps jCal property data with methods for manipulating parameters and values.

/**
 * Property constructor
 * @param {Array|string} jCal - Raw jCal property OR property name
 * @param {ICAL.Component} parent - Parent component (optional)
 */
class ICAL.Property {
  constructor(jCal, parent);
  
  // Properties
  readonly name: string;          // Property name (e.g., 'summary', 'dtstart')
  type: string;                   // Property value type
  jCal: Array;                   // Raw jCal representation
  parent: ICAL.Component;        // Parent component
}

Static Methods

/**
 * Parse property from iCalendar string
 * @param {string} str - Property string to parse
 * @param {Object} designSet - Design set for parsing rules (optional)
 * @returns {ICAL.Property} Parsed property
 */
static fromString(str, designSet);

Parameter Methods

Methods for managing property parameters (e.g., TZID, CN, ROLE).

/**
 * Get parameter value by name
 * @param {string} name - Parameter name (case-insensitive)
 * @returns {string|Array} Parameter value(s)
 */
getParameter(name);

/**
 * Set parameter value
 * @param {string} name - Parameter name
 * @param {string|Array} value - Parameter value(s)
 */
setParameter(name, value);

/**
 * Remove parameter
 * @param {string} name - Parameter name to remove
 */
removeParameter(name);

/**
 * Get iterator for all parameters
 * @returns {Object} Parameter iterator
 */
getParameterIterator();

/**
 * Check if parameter exists
 * @param {string} name - Parameter name
 * @returns {boolean} True if parameter exists
 */
hasParameter(name);

Value Methods

Methods for getting and setting property values.

/**
 * Get first value of the property
 * @returns {any} First property value
 */
getFirstValue();

/**
 * Get all values as array
 * @returns {Array} All property values
 */
getValues();

/**
 * Set single value
 * @param {any} value - Value to set
 */
setValue(value);

/**
 * Set multiple values
 * @param {Array} values - Array of values to set
 */
setValues(values);

/**
 * Get default type for this property
 * @returns {string} Default value type
 */
getDefaultType();

/**
 * Reset type to default
 */
resetType();

Serialization Methods

/**
 * Convert property to iCalendar string
 * @returns {string} Property as iCalendar string
 */
toICALString();

/**
 * Convert to string representation
 * @returns {string} String representation
 */
toString();

/**
 * Get property as jCal array
 * @returns {Array} Property in jCal format
 */
toJSON();

Usage Examples:

const ICAL = require('ical.js');

// Create property by name
const summaryProp = new ICAL.Property('summary');
summaryProp.setValue('Team Meeting');
console.log(summaryProp.toICALString()); // "SUMMARY:Team Meeting"

// Create datetime property with timezone
const startProp = new ICAL.Property('dtstart');
startProp.setValue(ICAL.Time.fromString('20230615T100000'));
startProp.setParameter('tzid', 'America/New_York');
console.log(startProp.toICALString()); // "DTSTART;TZID=America/New_York:20230615T100000"

// Parse from string
const prop = ICAL.Property.fromString('ATTENDEE;CN=John Doe;ROLE=REQ-PARTICIPANT:mailto:john@example.com');
console.log(prop.name);                      // 'attendee'
console.log(prop.getParameter('cn'));        // 'John Doe'
console.log(prop.getParameter('role'));      // 'REQ-PARTICIPANT'
console.log(prop.getFirstValue());           // 'mailto:john@example.com'

// Multi-value property
const categoriesProp = new ICAL.Property('categories');
categoriesProp.setValues(['work', 'meeting', 'important']);
console.log(categoriesProp.getValues());     // ['work', 'meeting', 'important']
console.log(categoriesProp.toICALString());  // "CATEGORIES:work,meeting,important"