ICAL. Component

Wraps a jCal component, adding convenience methods to add, remove and update subcomponents and properties.

Constructor

new Component(jCal, parent)

Creates a new ICAL.Component instance.

Parameters:
NameTypeDescription
jCalArray | String

Raw jCal component data OR name of new component

parentICAL.Component

Parent component to associate

Members

(readonly) name

The name of this component

Methods

addProperty(property) → {ICAL.Property}

Adds an ICAL.Property to the component.

Parameters:
NameTypeDescription
propertyICAL.Property

The property to add

Returns:

The passed in property

Type: 
ICAL.Property

addPropertyWithValue(name, value) → {ICAL.Property}

Helper method to add a property with a value to the component.

Parameters:
NameTypeDescription
nameString

Property name to add

valueString | Number | Object

Property value

Returns:

The created property

Type: 
ICAL.Property

addSubcomponent(component) → {ICAL.Component}

Adds a single sub component.

Parameters:
NameTypeDescription
componentICAL.Component

The component to add

Returns:

The passed in component

Type: 
ICAL.Component

getAllProperties(nameopt) → {Array.<ICAL.Property>}

Get all properties in the component, optionally filtered by name.

Parameters:
NameTypeAttributesDescription
nameString<optional>

Lowercase property name

Returns:

List of properties

Type: 
Array.<ICAL.Property>

getAllSubcomponents(nameopt) → {Array.<ICAL.Component>}

Finds all sub components, optionally filtering by name.

Parameters:
NameTypeAttributesDescription
nameString<optional>

Optional name to filter by

Returns:

The found sub components

Type: 
Array.<ICAL.Component>

getFirstProperty(nameopt) → (nullable) {ICAL.Property}

Finds the first property, optionally with the given name.

Parameters:
NameTypeAttributesDescription
nameString<optional>

Lowercase property name

Returns:

The found property

Type: 
ICAL.Property

getFirstPropertyValue(nameopt) → (nullable) {String}

Returns first property's value, if available.

Parameters:
NameTypeAttributesDescription
nameString<optional>

Lowercase property name

Returns:

The found property value.

Type: 
String

getFirstSubcomponent(nameopt) → (nullable) {ICAL.Component}

Finds first sub component, optionally filtered by name.

Parameters:
NameTypeAttributesDescription
nameString<optional>

Optional name to filter by

Returns:

The found subcomponent

Type: 
ICAL.Component

getTimeZoneByID(tzid) → {ICAL.Timezone}

Retrieve a time zone definition from the component tree, if any is present. If the tree contains no time zone definitions or the TZID cannot be matched, returns null.

Parameters:
NameTypeDescription
tzidString

The ID of the time zone to retrieve

Returns:

The time zone corresponding to the ID, or null

Type: 
ICAL.Timezone

hasProperty(name) → {Boolean}

Returns true when a named property exists.

Parameters:
NameTypeDescription
nameString

The property name

Returns:

True, when property is found

Type: 
Boolean

removeAllProperties(nameopt) → {Boolean}

Removes all properties associated with this component, optionally filtered by name.

Parameters:
NameTypeAttributesDescription
nameString<optional>

Lowercase property name

Returns:

True, when deleted

Type: 
Boolean

removeAllSubcomponents(nameopt)

Removes all components or (if given) all components by a particular name.

Parameters:
NameTypeAttributesDescription
nameString<optional>

Lowercase component name

removeProperty(nameOrProp) → {Boolean}

Removes a single property by name or the instance of the specific property.

Parameters:
NameTypeDescription
nameOrPropString | ICAL.Property

Property name or instance to remove

Returns:

True, when deleted

Type: 
Boolean

removeSubcomponent(nameOrComp) → {Boolean}

Removes a single component by name or the instance of a specific component.

Parameters:
NameTypeDescription
nameOrCompICAL.Component | String

Name of component, or component

Returns:

True when comp is removed

Type: 
Boolean

toJSON() → {Object}

Returns the Object representation of this component. The returned object is a live jCal object and should be cloned if modified.

Returns:
Type: 
Object

toString() → {String}

The string representation of this component.

Returns:
Type: 
String

updatePropertyWithValue(name, value) → {ICAL.Property}

Helper method that will update or create a property of the given name and sets its value. If multiple properties with the given name exist, only the first is updated.

Parameters:
NameTypeDescription
nameString

Property name to update

valueString | Number | Object

Property value

Returns:

The created property

Type: 
ICAL.Property

(static) fromString(str)

Create an ICAL.Component by parsing the passed iCalendar string.

Parameters:
NameTypeDescription
strString

The iCalendar string to parse