cisv 0.0.60 → 0.0.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,60 +0,0 @@
1
- #ifndef CISV_WRITER_H
2
- #define CISV_WRITER_H
3
-
4
- #include <stddef.h>
5
- #include <stdint.h>
6
- #include <stdio.h>
7
-
8
- #ifdef __cplusplus
9
- extern "C" {
10
- #endif
11
-
12
- typedef struct cisv_writer cisv_writer;
13
-
14
- // Writer configuration
15
- typedef struct {
16
- char delimiter;
17
- char quote_char;
18
- int always_quote;
19
- int use_crlf;
20
- const char *null_string;
21
- size_t buffer_size;
22
- } cisv_writer_config;
23
-
24
- // Create writer with default config
25
- cisv_writer *cisv_writer_create(FILE *output);
26
-
27
- // Create writer with custom config
28
- cisv_writer *cisv_writer_create_config(FILE *output, const cisv_writer_config *config);
29
-
30
- // Destroy writer and flush remaining data
31
- void cisv_writer_destroy(cisv_writer *writer);
32
-
33
- // Write a single field
34
- int cisv_writer_field(cisv_writer *writer, const char *data, size_t len);
35
-
36
- // Write a field from null-terminated string
37
- int cisv_writer_field_str(cisv_writer *writer, const char *str);
38
-
39
- // Write a numeric field
40
- int cisv_writer_field_int(cisv_writer *writer, int64_t value);
41
- int cisv_writer_field_double(cisv_writer *writer, double value, int precision);
42
-
43
- // End current row
44
- int cisv_writer_row_end(cisv_writer *writer);
45
-
46
- // Write complete row from array
47
- int cisv_writer_row(cisv_writer *writer, const char **fields, size_t count);
48
-
49
- // Flush buffer to output
50
- int cisv_writer_flush(cisv_writer *writer);
51
-
52
- // Get statistics
53
- size_t cisv_writer_bytes_written(const cisv_writer *writer);
54
- size_t cisv_writer_rows_written(const cisv_writer *writer);
55
-
56
- #ifdef __cplusplus
57
- }
58
- #endif
59
-
60
- #endif // CISV_WRITER_H
package/data.csv DELETED
@@ -1,11 +0,0 @@
1
- id,name,email,city
2
- 1,Alice Johnson,alice.johnson@email.com,New York
3
- 2,Bob Brown,bob.brown@email.com,Los Angeles
4
- 3,Charlie Davis,charlie.davis@email.com,"San Francisco"
5
- 4,Dana White,dana.white@email.com,Chicago
6
- 5,Ella Green,ella.green@email.com,New York
7
- 6,Frank Harris,frank.harris@email.com,Los Angeles
8
- 7,Grace Lee,grace.lee@email.com,"San Francisco"
9
- 8,Harry Black,harry.black@email.com,Chicago
10
- 9,Isla Scott,isla.scott@email.com,New York
11
- 10,Jack Moore,jack.moore@email.com,Los Angeles
package/index.d.ts DELETED
@@ -1,280 +0,0 @@
1
- declare module 'cisv' {
2
- /**
3
- * Configuration options for the CSV parser
4
- */
5
- export interface CisvConfig {
6
- /** Field delimiter character (default: ',') */
7
- delimiter?: string;
8
-
9
- /** Quote character (default: '"') */
10
- quote?: string;
11
-
12
- /** Escape character (null for RFC4180 "" style, default: null) */
13
- escape?: string | null;
14
-
15
- /** Comment character to skip lines (default: null) */
16
- comment?: string | null;
17
-
18
- /** Trim whitespace from fields (default: false) */
19
- trim?: boolean;
20
-
21
- /** Skip empty lines (default: false) */
22
- skipEmptyLines?: boolean;
23
-
24
- /** Use relaxed parsing rules (default: false) */
25
- relaxed?: boolean;
26
-
27
- /** Skip lines with parse errors (default: false) */
28
- skipLinesWithError?: boolean;
29
-
30
- /** Maximum row size in bytes (0 = unlimited, default: 0) */
31
- maxRowSize?: number;
32
-
33
- /** Start parsing from line N (1-based, default: 1) */
34
- fromLine?: number;
35
-
36
- /** Stop parsing at line N (0 = until end, default: 0) */
37
- toLine?: number;
38
- }
39
-
40
- /**
41
- * Parsed row is an array of string values
42
- */
43
- export type ParsedRow = string[];
44
-
45
- /**
46
- * Statistics about the parsing operation
47
- */
48
- export interface ParseStats {
49
- /** Number of rows parsed */
50
- rowCount: number;
51
-
52
- /** Number of fields per row */
53
- fieldCount: number;
54
-
55
- /** Total bytes processed */
56
- totalBytes: number;
57
-
58
- /** Time taken to parse in milliseconds */
59
- parseTime: number;
60
-
61
- /** Current line number being processed */
62
- currentLine: number;
63
- }
64
-
65
- /**
66
- * Information about registered transforms
67
- */
68
- export interface TransformInfo {
69
- /** Number of C transforms registered */
70
- cTransformCount: number;
71
-
72
- /** Number of JavaScript transforms registered */
73
- jsTransformCount: number;
74
-
75
- /** Field indices that have transforms */
76
- fieldIndices: number[];
77
- }
78
-
79
- /**
80
- * Transform function signature for field transforms
81
- */
82
- export type FieldTransformFn = (value: string, fieldIndex: number) => string;
83
-
84
- /**
85
- * Transform function signature for row transforms
86
- * @param row - Array of field values
87
- * @param rowObj - Object with field names as keys (if header is known)
88
- * @returns Modified row array, object, or null to skip the row
89
- */
90
- export type RowTransformFn = (
91
- row: string[],
92
- rowObj?: Record<string, string>
93
- ) => string[] | Record<string, string> | null;
94
-
95
- /**
96
- * Built-in transform types
97
- */
98
- export type TransformType =
99
- | 'uppercase'
100
- | 'lowercase'
101
- | 'trim'
102
- | 'to_int'
103
- | 'int'
104
- | 'to_float'
105
- | 'float'
106
- | 'hash_sha256'
107
- | 'sha256'
108
- | 'base64_encode'
109
- | 'base64';
110
-
111
- /**
112
- * Transform context for advanced transforms
113
- */
114
- export interface TransformContext {
115
- /** Encryption/hash key if needed */
116
- key?: string;
117
-
118
- /** Initialization vector */
119
- iv?: string;
120
-
121
- /** Extra context data */
122
- extra?: any;
123
- }
124
-
125
- /**
126
- * High-performance CSV parser with SIMD optimization
127
- */
128
- export class cisvParser {
129
- /**
130
- * Create a new CSV parser instance
131
- * @param config - Optional configuration options
132
- */
133
- constructor(config?: CisvConfig);
134
-
135
- /**
136
- * Parse CSV file synchronously
137
- * @param path - Path to CSV file
138
- * @returns Array of parsed rows
139
- */
140
- parseSync(path: string): ParsedRow[];
141
-
142
- /**
143
- * Parse CSV file asynchronously
144
- * @param path - Path to CSV file
145
- * @returns Promise resolving to array of parsed rows
146
- */
147
- parse(path: string): Promise<ParsedRow[]>;
148
-
149
- /**
150
- * Parse CSV string content
151
- * @param csv - CSV string content
152
- * @returns Array of parsed rows
153
- */
154
- parseString(csv: string): ParsedRow[];
155
-
156
- /**
157
- * Write chunk of data for streaming parsing
158
- * @param chunk - Data chunk as Buffer or string
159
- */
160
- write(chunk: Buffer | string): void;
161
-
162
- /**
163
- * Signal end of streaming data
164
- */
165
- end(): void;
166
-
167
- /**
168
- * Get accumulated parsed rows
169
- * @returns Array of parsed rows
170
- */
171
- getRows(): ParsedRow[];
172
-
173
- /**
174
- * Clear accumulated data
175
- */
176
- clear(): void;
177
-
178
- /**
179
- * Set parser configuration
180
- * @param config - Configuration options
181
- */
182
- setConfig(config: CisvConfig): void;
183
-
184
- /**
185
- * Get current parser configuration
186
- * @returns Current configuration
187
- */
188
- getConfig(): CisvConfig;
189
-
190
- /**
191
- * Add field transform by index or name
192
- * @param field - Field index (0-based) or field name, use -1 for all fields
193
- * @param transform - Transform type or custom function
194
- * @param context - Optional transform context
195
- * @returns Parser instance for chaining
196
- */
197
- transform(
198
- field: number | string,
199
- transform: TransformType | FieldTransformFn,
200
- context?: TransformContext
201
- ): this;
202
-
203
- /**
204
- * Add row-level transform
205
- * @param transform - Row transform function
206
- * @returns Parser instance for chaining
207
- */
208
- transformRow(transform: RowTransformFn): this;
209
-
210
- /**
211
- * Set header fields for field name mapping
212
- * @param fields - Array of field names
213
- * @returns Parser instance for chaining
214
- */
215
- setHeader(fields: string[]): this;
216
-
217
- /**
218
- * Remove transform for specific field
219
- * @param field - Field index or name
220
- * @returns Parser instance for chaining
221
- */
222
- removeTransform(field: number | string): this;
223
-
224
- /**
225
- * Clear all transforms
226
- * @returns Parser instance for chaining
227
- */
228
- clearTransforms(): this;
229
-
230
- /**
231
- * Get parsing statistics
232
- * @returns Statistics object
233
- */
234
- getStats(): ParseStats;
235
-
236
- /**
237
- * Get information about registered transforms
238
- * @returns Transform information
239
- */
240
- getTransformInfo(): TransformInfo;
241
-
242
- /**
243
- * Destroy parser and free resources
244
- */
245
- destroy(): void;
246
-
247
- /**
248
- * Count rows in CSV file without parsing
249
- * @param path - Path to CSV file
250
- * @returns Number of rows
251
- */
252
- static countRows(path: string): number;
253
-
254
- /**
255
- * Count rows with specific configuration
256
- * @param path - Path to CSV file
257
- * @param config - Configuration options
258
- * @returns Number of rows
259
- */
260
- static countRowsWithConfig(path: string, config?: CisvConfig): number;
261
- }
262
-
263
- /**
264
- * Transform type constants
265
- */
266
- export const TransformType: {
267
- readonly UPPERCASE: 'uppercase';
268
- readonly LOWERCASE: 'lowercase';
269
- readonly TRIM: 'trim';
270
- readonly TO_INT: 'to_int';
271
- readonly TO_FLOAT: 'to_float';
272
- readonly HASH_SHA256: 'hash_sha256';
273
- readonly BASE64_ENCODE: 'base64_encode';
274
- };
275
-
276
- /**
277
- * Library version
278
- */
279
- export const version: string;
280
- }
File without changes