<commit_before>import { isAlpha } from "./util";

/**
 * Implementation of a Content Line from RFC 5545
 *
 * @author <NAME> <<EMAIL>>
 *
 * Chapter 3.1 defines the content line. This implementation will use it as an
 * abstract class which can be extended later by the specific content types.
 *
 * This class defines all of the general features specified by the chapter,
 * while leaving the specific features required by individual component objects
 * unfilled.
 */
export class ContentLine {
    private _name: string;
    private _param: string[];
    private _value: string;

    constructor(inName: string, inParam: string[], inValue: string) {
        this.name = inName;
        this.param = inParam;
        this.value = inValue;
    }

    /* Getters */

    get name(): string {
        return this._name;
    }

    get param(): string[] {
        return this._param;
    }

    get value(): string {
        return this._value;
    }

    /* Setters */

    set name(newName: string) {
        if (isAlpha(newName)) {
            this._name = newName;
        }
        else {
            throw new TypeError("'name' must be alphabetic!");
        }
    }

    set param(newParam: string[]) {
        this._param = newParam;
    }

    set value(newValue: string) {
        if (isAlpha(newValue)) {
            this._value = newValue;
        }
    }

    /**
     * Folds lines into 74 octet sections
     * 
     * @author <NAME> <<EMAIL>>
     * 
     * TODO: Make sure that this handles multi-octed UTF-8 segments properly.
     */
    static fold(line: string): string {
        return line.match(/(.{1,74})/g).join('\r\n ');
    }

    /**
     * Generates a folded content line to use to create the final file.
     * 
     * @author <NAME> <<EMAIL>>
     */
    public generate(): string {
        let outputLine = this.name;

        this.param.forEach((param) => {
            outputLine += ';';
            outputLine += param;
        });

        outputLine += ':' + this.value + '\r\n';

        return ContentLine.fold(outputLine);
    }
}
<commit_msg>Refactors params to allow for multiple paramaters.<commit_after>import { isAlpha } from "./util";

/**
 * Implementation of a Content Line from RFC 5545
 *
 * @author <NAME> <<EMAIL>>
 *
 * Chapter 3.1 defines the content line. This implementation will use it as an
 * abstract class which can be extended later by the specific content types.
 *
 * This class defines all of the general features specified by the chapter,
 * while leaving the specific features required by individual component objects
 * unfilled.
 */
export class ContentLine {
    private _name: string;
    private _params: string[] = [];
    private _value: string;

    constructor(inName: string, inParams: string[], inValue: string) {
        this.name = inName;
        this._params = inParams;
        this.value = inValue;
    }

    /* Getters */

    get name(): string {
        return this._name;
    }

    get params(): string[] {
        return this._params;
    }

    get value(): string {
        return this._value;
    }

    /* Setters */

    set name(newName: string) {
        if (isAlpha(newName)) {
            this._name = newName;
        }
        else {
            throw new TypeError("'name' must be alphabetic!");
        }
    }

    set value(newValue: string) {
        if (isAlpha(newValue)) {
            this._value = newValue;
        }
    }

    /**
     * Folds lines into 74 octet sections
     * 
     * @author <NAME> <<EMAIL>>
     * 
     * TODO: Make sure that this handles multi-octed UTF-8 segments properly.
     */
    static fold(line: string): string {
        return line.match(/(.{1,74})/g).join('\r\n ');
    }

    /**
     * Generates a folded content line to use to create the final file.
     * 
     * @author <NAME> <<EMAIL>>
     */
    public generate(): string {
        let outputLine = this.name;

        this.params.forEach((param) => {
            outputLine += ';';
            outputLine += param;
        });

        outputLine += ':' + this.value + '\r\n';

        return ContentLine.fold(outputLine);
    }
}

{'fraction_non_alphanumeric': 0.12080212611741967, 'fraction_numerical': 0.005798502053636144, 'mean_word_length': 2.021897810218978, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4396152', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1174, 'n_words': 371}