|
1 |
| -export interface ISharedOptions { |
| 1 | +interface SharedConverterOptions { |
2 | 2 | /**
|
3 | 3 | * Specifies the different types of delimiters
|
4 | 4 | */
|
@@ -56,7 +56,17 @@ export interface ISharedOptions {
|
56 | 56 | preventCsvInjection?: boolean;
|
57 | 57 | }
|
58 | 58 |
|
59 |
| -export interface IFullOptions extends ISharedOptions { |
| 59 | +export interface Csv2JsonOptions extends SharedConverterOptions { |
| 60 | + /** |
| 61 | + * Specify the header fields in the event that the CSV does not container a header line |
| 62 | + * |
| 63 | + * If you want to generate a nested object (ie. {info : {name: 'Mike'}}), then use `.` characters in the string to denote a nested field, like ['info.name'] |
| 64 | + * If your CSV has a header line included, then don't specify the option to utilize the default values that will be parsed from the CSV. |
| 65 | + */ |
| 66 | + headerFields?: string[]; |
| 67 | +} |
| 68 | + |
| 69 | +export interface Json2CsvOptions extends SharedConverterOptions { |
60 | 70 | /**
|
61 | 71 | * Should all documents have the same schema?
|
62 | 72 | * @default false
|
@@ -121,11 +131,11 @@ export interface IFullOptions extends ISharedOptions {
|
121 | 131 | }
|
122 | 132 |
|
123 | 133 | export function json2csv(data: object[],
|
124 |
| - callback: (err?: Error, csv?: string) => void, options?: IFullOptions): void; |
| 134 | + callback: (err?: Error, csv?: string) => void, options?: Json2CsvOptions): void; |
125 | 135 |
|
126 |
| -export function json2csvAsync(data: object[], options?: IFullOptions): Promise<string>; |
| 136 | +export function json2csvAsync(data: object[], options?: Json2CsvOptions): Promise<string>; |
127 | 137 |
|
128 | 138 | export function csv2json(csv: string,
|
129 |
| - callback: (err?: Error, data?: any[]) => void, options?: ISharedOptions): void; |
| 139 | + callback: (err?: Error, data?: any[]) => void, options?: Csv2JsonOptions): void; |
130 | 140 |
|
131 |
| -export function csv2jsonAsync(csv: string, options?: ISharedOptions): Promise<any[]>; |
| 141 | +export function csv2jsonAsync(csv: string, options?: Csv2JsonOptions): Promise<any[]>; |
0 commit comments