UNPKG

1.35 kBTypeScriptView Raw
1import { FieldPosition } from "./FieldPosition";
2export type FieldOptions = {
3 name: string;
4 kind?: FieldPosition;
5 values?: string[];
6};
7/**
8 * A name-value pair representing a single field
9 * transmitted in an HTTP Request or Response.
10 *
11 * The kind will dictate metadata placement within
12 * an HTTP message.
13 *
14 * All field names are case insensitive and
15 * case-variance must be treated as equivalent.
16 * Names MAY be normalized but SHOULD be preserved
17 * for accuracy during transmission.
18 */
19export declare class Field {
20 readonly name: string;
21 readonly kind: FieldPosition;
22 values: string[];
23 constructor({ name, kind, values }: FieldOptions);
24 /**
25 * Appends a value to the field.
26 *
27 * @param value The value to append.
28 */
29 add(value: string): void;
30 /**
31 * Overwrite existing field values.
32 *
33 * @param values The new field values.
34 */
35 set(values: string[]): void;
36 /**
37 * Remove all matching entries from list.
38 *
39 * @param value Value to remove.
40 */
41 remove(value: string): void;
42 /**
43 * Get comma-delimited string.
44 *
45 * @returns String representation of {@link Field}.
46 */
47 toString(): string;
48 /**
49 * Get string values as a list
50 *
51 * @returns Values in {@link Field} as a list.
52 */
53 get(): string[];
54}