UNPKG

600 BJavaScriptView Raw
1import { FieldPosition } from "./FieldPosition";
2export class Field {
3 constructor({ name, kind = FieldPosition.HEADER, values = [] }) {
4 this.name = name;
5 this.kind = kind;
6 this.values = values;
7 }
8 add(value) {
9 this.values.push(value);
10 }
11 set(values) {
12 this.values = values;
13 }
14 remove(value) {
15 this.values = this.values.filter((v) => v !== value);
16 }
17 toString() {
18 return this.values.map((v) => (v.includes(",") || v.includes(" ") ? `"${v}"` : v)).join(", ");
19 }
20 get() {
21 return this.values;
22 }
23}