import { COLON, EQUAL, SPACE, SEMICOLON, BEGIN, END, ComponentType } from './constants' import { KeyValue, TreeType } from './types' /** * Parses content lines according to RFC5545 {@link https://tools.ietf.org/html/rfc5545#section-3.1} * * @remarks not exposed for external use * * @example input: * * ``` * DESCRIPTION:This is a lo * ng description * that exists on a long line. * ``` * * @example output: * * ``` * DESCRIPTION:This is a long description that exists on a long line. * ``` * * @param lines array of lines * * @returns arrays of lines with content lines merged into a single string for each occurance * */ const preprocessing = (lines:string[]):string[] => { let output:string[] = [] for(let i=0;i { const lines:string[] = preprocessing(rawLines) return process(lines) } /** * Returns a JSON tree based on ICS format * * @param lines raw lines preprocessed for multi content lines * @param intend optional, used for debugging tree data */ const process = (lines:string[], intend:number = 0):TreeType => { const output:TreeType = {} let componentName:ComponentType for(let i=0;i { if(key.includes(SEMICOLON)){ const keys = key.split(SEMICOLON) const k = keys[0] let obj:KeyValue = { key: k, __value__: value } for(let i=1;i