UNPKG

775 BTypeScriptView Raw
1/**
2 * A jar of form fields to store form data by handling
3 * array gracefully
4 */
5export declare class FormFields {
6 #private;
7 constructor(config: {
8 convertEmptyStringsToNull: boolean;
9 });
10 /**
11 * Add a new key/value pair. The keys with array like
12 * expressions are handled properly.
13 *
14 * @example
15 * ```
16 * formfields.add('username', 'virk')
17 *
18 * // array
19 * formfields.add('username[]', 'virk')
20 * formfields.add('username[]', 'nikk')
21 *
22 * // Indexed keys are orderd properly
23 * formfields.add('username[1]', 'virk')
24 * formfields.add('username[0]', 'nikk')
25 * ```
26 */
27 add(key: string, value: any): void;
28 /**
29 * Returns the copy of form fields
30 */
31 get(): any;
32}