index.js
function revert(object) {
  let lines = [];

  for (let key in object) {
    let value = object[key];
    if (Array.isArray(value)) {
      value.forEach((item) => {
        lines.push(`BEGIN:${key}`);
        lines.push(revert(item));
        lines.push(`END:${key}`);
      });
    } else {
      let fullLine = `${key}:${value}`;
      do {
        // According to ical spec, lines of text should be no longer
        // than 75 octets
        lines.push(fullLine.substr(0, 75));
        fullLine = ' ' + fullLine.substr(75);
      } while (fullLine.length > 1);
    }
  }

  return lines.join('\n');
}
function revert(object) {
  let lines = [];

  for (let key in object) {
    let value = object[key];
    if (Array.isArray(value)) {
      value.forEach((item) => {
        lines.push(`BEGIN:${key}`);
        lines.push(revert(item));
        lines.push(`END:${key}`);
      });
    } else {
      let fullLine = `${key}:${value}`;
      do {
        // According to ical spec, lines of text should be no longer
        // than 75 octets
        lines.push(fullLine.substr(0, 75));
        fullLine = ' ' + fullLine.substr(75);
      } while (fullLine.length > 1);
    }
  }

  return lines.join('\n');
}
function revert ( object ) { let lines = [ ] ; for ( let key in object ) { let value = object [ key ] ; if ( Array . isArray ( value ) ) { value . forEach ( ( item ) => { lines . push ( ` ${ key } ` ) ; lines . push ( revert ( item ) ) ; lines . push ( ` ${ key } ` ) ; } ) ; } else { let fullLine = ` ${ key } ${ value } ` ; do { // According to ical spec, lines of text should be no longer // than 75 octets lines . push ( fullLine . substr ( 0 , 75 ) ) ; fullLine = ' ' + fullLine . substr ( 75 ) ; } while ( fullLine . length > 1 ) ; } } return lines . join ( '\n' ) ; }
Take JSON, revert back to ical
@param {Object} object
@return {String}
Take JSON revert back to ical