Commit cda27382 authored by Mark Stenglein's avatar Mark Stenglein

Add the first class!

- Begins implementation of the ContentLine class as well as
  starts the util module.
parent 302b94e5
......@@ -116,6 +116,18 @@ breaks.
- All other property values, unless otherwise stated, are **case-sensitive**.
#### 3.1.1. List and Field Separators
- Properties which allow lists of values will have those values separated by
the **COMMA** character.
- There is no significance to the order of values in a list.
- For values specified in quoted-strings, each quoted-string should be
separated by a **COMMA** character.
- Some property values are defined in terms of multiple parts. Each value
**MUST** be separated by a **SEMICOLON** character.
#### 3.1.2. Multiple Values
#### 3.1.3. Binary Content
#### 3.1.4. Character Set
......
import { isAlpha } from "./util";
/**
* Implementation of a Content Line from RFC 5545
*
* @author Mark Stenglein <mark@stengle.in>
*
* 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;
}
}
}
\ No newline at end of file
export function isAlpha(input: string): boolean {
return /^[a-zA-Z]+$/.test(input);
}
\ No newline at end of file
{
"files": [
"src/**/*.ts",
"src/**/*.ts"
],
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"noImplicitAny": true,
"target": "es5"
"target": "es2015"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment