export function initTextArray(ta: Array<string>): Array<string> {
    if (ta) {
        return ta.concat("");
    } else {
        return [""];
    }
}

export function prepareTextArrayForWrite(ta: Array<string>): Array<string>|undefined {
    if (ta.length === 1 && ta[0] === "") {
        return undefined;   
    } else {
        return cleanTextArrayFromEmptyString(ta);
    }
}

export function cleanTextArrayFromEmptyString(ta: Array<string>): Array<string> {
    return ta.filter((val)=>{return val.trim()!=="";});
}

export function extendTextArrayWithEmptyString(ta: Array<string>): Array<string> {
    if (!ta.includes("")) {
        return [...ta, ""];
    } else {
      return ta;
    }
}