Helper functions used in various places within ical.js
- Source
Methods
(static) binsearchInsert(list, seekVal, cmpfunc) → {Number}
Find the index for insertion using binary search.
Name | Type | Description |
---|---|---|
list | Array | The list to search |
seekVal | ? | The value to insert |
cmpfunc | function | The comparison func, that can compare two seekVals |
- Source
The insert position
- Type:
- Number
(static) clone(aSrc, aDeepopt) → {*}
Clone the passed object or primitive. By default a shallow clone will be executed.
Name | Type | Attributes | Description |
---|---|---|---|
aSrc | * | The thing to clone | |
aDeep | Boolean | <optional> | If true, a deep clone will be performed |
- Source
The copy of the thing
- Type:
- *
(static) extend(source, target) → {Object}
Poor-man's cross-browser object extension. Doesn't support all the features, but enough for our usage. Note that the target's properties are not overwritten with the source properties.
Name | Type | Description |
---|---|---|
source | Object | The object to extend |
target | Object | The object to extend with |
- Source
Returns the target.
- Type:
- Object
var child = ICAL.helpers.extend(parent, {
"bar": 123
});
(static) foldline(aLine) → {String}
Performs iCalendar line folding. A line ending character is inserted and the next line begins with a whitespace.
Name | Type | Description |
---|---|---|
aLine | String | The line to fold |
- Source
The folded line
- Type:
- String
SUMMARY:This line will be fold
ed right in the middle of a word.
(static) formatClassType(data, type) → {?}
Creates or returns a class instance of a given type with the initialization data if the data is not already an instance of the given type.
Name | Type | Description |
---|---|---|
data | Object | object initialization data |
type | Object | object type (like ICAL.Time) |
- Source
An instance of the found type.
- Type:
- ?
var time = new ICAL.Time(...);
var result = ICAL.helpers.formatClassType(time, ICAL.Time);
(result instanceof ICAL.Time)
// => true
result = ICAL.helpers.formatClassType({}, ICAL.Time);
(result isntanceof ICAL.Time)
// => true
(static) isStrictlyNaN(number) → {Boolean}
Checks if the given type is of the number type and also NaN.
Name | Type | Description |
---|---|---|
number | Number | The number to check |
- Source
True, if the number is strictly NaN
- Type:
- Boolean
(static) pad2(data) → {String}
Pads the given string or number with zeros so it will have at least two characters.
Name | Type | Description |
---|---|---|
data | String | | The string or number to pad |
- Source
The number padded as a string
- Type:
- String
(static) strictParseInt(string) → {Number}
Parses a string value that is expected to be an integer, when the valid is not an integer throws a decoration error.
Name | Type | Description |
---|---|---|
string | String | Raw string input |
- Source
Parsed integer
- Type:
- Number
(static) trunc(number) → {Number}
Truncates the given number, correctly handling negative numbers.
Name | Type | Description |
---|---|---|
number | Number | The number to truncate |
- Source
The truncated number
- Type:
- Number
(static) unescapedIndexOf(buffer, search, pos) → {Number}
Identical to indexOf but will only match values when they are not preceded by a backslash character.
Name | Type | Description |
---|---|---|
buffer | String | String to search |
search | String | Value to look for |
pos | Number | Start position |
- Source
The position, or -1 if not found
- Type:
- Number
(static) updateTimezones(vcal) → {ICAL.Component}
Compiles a list of all referenced TZIDs in all subcomponents and removes any extra VTIMEZONE subcomponents. In addition, if any TZIDs are referenced by a component, but a VTIMEZONE does not exist, an attempt will be made to generate a VTIMEZONE using ICAL.TimezoneService.
Name | Type | Description |
---|---|---|
vcal | ICAL. | The top-level VCALENDAR component. |
- Source
The ICAL.Component that was passed in.
- Type:
- ICAL.
Component