build/ical.js
function formatClassType(data, type) {
    if (typeof(data) === 'undefined') {
      return undefined;
    }

    if (data instanceof type) {
      return data;
    }
    return new type(data);
  }
function formatClassType(data, type) {
    if (typeof(data) === 'undefined') {
      return undefined;
    }

    if (data instanceof type) {
      return data;
    }
    return new type(data);
  }
function formatClassType ( data , type ) { if ( typeof ( data ) === 'undefined' ) { return undefined ; } if ( data instanceof type ) { return data ; } return new type ( data ) ; }
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.

@example
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


@param {Object} data       object initialization data
@param {Object} type       object type (like ICAL.Time)
@return {?}                An instance of the found 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 .