web-csv-toolbox 0.10.3-next-ee4125d4c2daeac2840037eddcc4335c766a489a → 0.10.3-pr317-874058b020bd8e180674e73a11c0abbd258327a5

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.
Files changed (199) hide show
  1. package/package.json +1 -1
  2. package/dist/cjs/Lexer.cjs +0 -2
  3. package/dist/cjs/Lexer.cjs.map +0 -1
  4. package/dist/cjs/LexerTransformer.cjs +0 -2
  5. package/dist/cjs/LexerTransformer.cjs.map +0 -1
  6. package/dist/cjs/RecordAssembler.cjs +0 -2
  7. package/dist/cjs/RecordAssembler.cjs.map +0 -1
  8. package/dist/cjs/RecordAssemblerTransformer.cjs +0 -2
  9. package/dist/cjs/RecordAssemblerTransformer.cjs.map +0 -1
  10. package/dist/cjs/_virtual/_web-csv-toolbox-wasm.cjs +0 -2
  11. package/dist/cjs/_virtual/_web-csv-toolbox-wasm.cjs.map +0 -1
  12. package/dist/cjs/_virtual/web_csv_toolbox_wasm_bg.wasm.cjs +0 -2
  13. package/dist/cjs/_virtual/web_csv_toolbox_wasm_bg.wasm.cjs.map +0 -1
  14. package/dist/cjs/assertCommonOptions.cjs +0 -2
  15. package/dist/cjs/assertCommonOptions.cjs.map +0 -1
  16. package/dist/cjs/common/constants.cjs +0 -2
  17. package/dist/cjs/common/constants.cjs.map +0 -1
  18. package/dist/cjs/common/errors.cjs +0 -2
  19. package/dist/cjs/common/errors.cjs.map +0 -1
  20. package/dist/cjs/commonParseErrorHandling.cjs +0 -2
  21. package/dist/cjs/commonParseErrorHandling.cjs.map +0 -1
  22. package/dist/cjs/constants.cjs +0 -2
  23. package/dist/cjs/constants.cjs.map +0 -1
  24. package/dist/cjs/getOptionsFromResponse.cjs +0 -2
  25. package/dist/cjs/getOptionsFromResponse.cjs.map +0 -1
  26. package/dist/cjs/loadWASM.cjs +0 -2
  27. package/dist/cjs/loadWASM.cjs.map +0 -1
  28. package/dist/cjs/loadWASM.web.cjs +0 -2
  29. package/dist/cjs/loadWASM.web.cjs.map +0 -1
  30. package/dist/cjs/parse.cjs +0 -2
  31. package/dist/cjs/parse.cjs.map +0 -1
  32. package/dist/cjs/parseBinary.cjs +0 -2
  33. package/dist/cjs/parseBinary.cjs.map +0 -1
  34. package/dist/cjs/parseBinaryToArraySync.cjs +0 -2
  35. package/dist/cjs/parseBinaryToArraySync.cjs.map +0 -1
  36. package/dist/cjs/parseBinaryToIterableIterator.cjs +0 -2
  37. package/dist/cjs/parseBinaryToIterableIterator.cjs.map +0 -1
  38. package/dist/cjs/parseBinaryToStream.cjs +0 -2
  39. package/dist/cjs/parseBinaryToStream.cjs.map +0 -1
  40. package/dist/cjs/parseResponse.cjs +0 -2
  41. package/dist/cjs/parseResponse.cjs.map +0 -1
  42. package/dist/cjs/parseResponseToStream.cjs +0 -2
  43. package/dist/cjs/parseResponseToStream.cjs.map +0 -1
  44. package/dist/cjs/parseString.cjs +0 -2
  45. package/dist/cjs/parseString.cjs.map +0 -1
  46. package/dist/cjs/parseStringStream.cjs +0 -2
  47. package/dist/cjs/parseStringStream.cjs.map +0 -1
  48. package/dist/cjs/parseStringStreamToStream.cjs +0 -2
  49. package/dist/cjs/parseStringStreamToStream.cjs.map +0 -1
  50. package/dist/cjs/parseStringToArraySync.cjs +0 -2
  51. package/dist/cjs/parseStringToArraySync.cjs.map +0 -1
  52. package/dist/cjs/parseStringToArraySyncWASM.cjs +0 -2
  53. package/dist/cjs/parseStringToArraySyncWASM.cjs.map +0 -1
  54. package/dist/cjs/parseStringToIterableIterator.cjs +0 -2
  55. package/dist/cjs/parseStringToIterableIterator.cjs.map +0 -1
  56. package/dist/cjs/parseStringToStream.cjs +0 -2
  57. package/dist/cjs/parseStringToStream.cjs.map +0 -1
  58. package/dist/cjs/parseUint8ArrayStream.cjs +0 -2
  59. package/dist/cjs/parseUint8ArrayStream.cjs.map +0 -1
  60. package/dist/cjs/parseUint8ArrayStreamToStream.cjs +0 -2
  61. package/dist/cjs/parseUint8ArrayStreamToStream.cjs.map +0 -1
  62. package/dist/cjs/utils/convertBinaryToString.cjs +0 -2
  63. package/dist/cjs/utils/convertBinaryToString.cjs.map +0 -1
  64. package/dist/cjs/utils/convertIterableIteratorToAsync.cjs +0 -2
  65. package/dist/cjs/utils/convertIterableIteratorToAsync.cjs.map +0 -1
  66. package/dist/cjs/utils/convertStreamToAsyncIterableIterator.cjs +0 -2
  67. package/dist/cjs/utils/convertStreamToAsyncIterableIterator.cjs.map +0 -1
  68. package/dist/cjs/utils/convertThisAsyncIterableIteratorToArray.cjs +0 -2
  69. package/dist/cjs/utils/convertThisAsyncIterableIteratorToArray.cjs.map +0 -1
  70. package/dist/cjs/utils/escapeRegExp.cjs +0 -2
  71. package/dist/cjs/utils/escapeRegExp.cjs.map +0 -1
  72. package/dist/cjs/utils/parseMime.cjs +0 -2
  73. package/dist/cjs/utils/parseMime.cjs.map +0 -1
  74. package/dist/cjs/utils/pipeline.cjs +0 -2
  75. package/dist/cjs/utils/pipeline.cjs.map +0 -1
  76. package/dist/cjs/web-csv-toolbox.cjs +0 -2
  77. package/dist/cjs/web-csv-toolbox.cjs.map +0 -1
  78. package/dist/es/Lexer.js +0 -225
  79. package/dist/es/Lexer.js.map +0 -1
  80. package/dist/es/LexerTransformer.js +0 -29
  81. package/dist/es/LexerTransformer.js.map +0 -1
  82. package/dist/es/RecordAssembler.js +0 -73
  83. package/dist/es/RecordAssembler.js.map +0 -1
  84. package/dist/es/RecordAssemblerTransformer.js +0 -31
  85. package/dist/es/RecordAssemblerTransformer.js.map +0 -1
  86. package/dist/es/_virtual/_web-csv-toolbox-wasm.js +0 -185
  87. package/dist/es/_virtual/_web-csv-toolbox-wasm.js.map +0 -1
  88. package/dist/es/_virtual/web_csv_toolbox_wasm_bg.wasm.js +0 -4
  89. package/dist/es/_virtual/web_csv_toolbox_wasm_bg.wasm.js.map +0 -1
  90. package/dist/es/assertCommonOptions.js +0 -31
  91. package/dist/es/assertCommonOptions.js.map +0 -1
  92. package/dist/es/common/constants.js +0 -6
  93. package/dist/es/common/constants.js.map +0 -1
  94. package/dist/es/common/errors.js +0 -20
  95. package/dist/es/common/errors.js.map +0 -1
  96. package/dist/es/commonParseErrorHandling.js +0 -13
  97. package/dist/es/commonParseErrorHandling.js.map +0 -1
  98. package/dist/es/constants.js +0 -8
  99. package/dist/es/constants.js.map +0 -1
  100. package/dist/es/getOptionsFromResponse.js +0 -20
  101. package/dist/es/getOptionsFromResponse.js.map +0 -1
  102. package/dist/es/loadWASM.js +0 -9
  103. package/dist/es/loadWASM.js.map +0 -1
  104. package/dist/es/loadWASM.web.js +0 -8
  105. package/dist/es/loadWASM.web.js.map +0 -1
  106. package/dist/es/parse.js +0 -39
  107. package/dist/es/parse.js.map +0 -1
  108. package/dist/es/parseBinary.js +0 -35
  109. package/dist/es/parseBinary.js.map +0 -1
  110. package/dist/es/parseBinaryToArraySync.js +0 -15
  111. package/dist/es/parseBinaryToArraySync.js.map +0 -1
  112. package/dist/es/parseBinaryToIterableIterator.js +0 -15
  113. package/dist/es/parseBinaryToIterableIterator.js.map +0 -1
  114. package/dist/es/parseBinaryToStream.js +0 -15
  115. package/dist/es/parseBinaryToStream.js.map +0 -1
  116. package/dist/es/parseResponse.js +0 -32
  117. package/dist/es/parseResponse.js.map +0 -1
  118. package/dist/es/parseResponseToStream.js +0 -18
  119. package/dist/es/parseResponseToStream.js.map +0 -1
  120. package/dist/es/parseString.js +0 -38
  121. package/dist/es/parseString.js.map +0 -1
  122. package/dist/es/parseStringStream.js +0 -23
  123. package/dist/es/parseStringStream.js.map +0 -1
  124. package/dist/es/parseStringStreamToStream.js +0 -14
  125. package/dist/es/parseStringStreamToStream.js.map +0 -1
  126. package/dist/es/parseStringToArraySync.js +0 -17
  127. package/dist/es/parseStringToArraySync.js.map +0 -1
  128. package/dist/es/parseStringToArraySyncWASM.js +0 -24
  129. package/dist/es/parseStringToArraySyncWASM.js.map +0 -1
  130. package/dist/es/parseStringToIterableIterator.js +0 -17
  131. package/dist/es/parseStringToIterableIterator.js.map +0 -1
  132. package/dist/es/parseStringToStream.js +0 -24
  133. package/dist/es/parseStringToStream.js.map +0 -1
  134. package/dist/es/parseUint8ArrayStream.js +0 -23
  135. package/dist/es/parseUint8ArrayStream.js.map +0 -1
  136. package/dist/es/parseUint8ArrayStreamToStream.js +0 -22
  137. package/dist/es/parseUint8ArrayStreamToStream.js.map +0 -1
  138. package/dist/es/utils/convertBinaryToString.js +0 -9
  139. package/dist/es/utils/convertBinaryToString.js.map +0 -1
  140. package/dist/es/utils/convertIterableIteratorToAsync.js +0 -14
  141. package/dist/es/utils/convertIterableIteratorToAsync.js.map +0 -1
  142. package/dist/es/utils/convertStreamToAsyncIterableIterator.js +0 -11
  143. package/dist/es/utils/convertStreamToAsyncIterableIterator.js.map +0 -1
  144. package/dist/es/utils/convertThisAsyncIterableIteratorToArray.js +0 -10
  145. package/dist/es/utils/convertThisAsyncIterableIteratorToArray.js.map +0 -1
  146. package/dist/es/utils/escapeRegExp.js +0 -6
  147. package/dist/es/utils/escapeRegExp.js.map +0 -1
  148. package/dist/es/utils/parseMime.js +0 -15
  149. package/dist/es/utils/parseMime.js.map +0 -1
  150. package/dist/es/utils/pipeline.js +0 -18
  151. package/dist/es/utils/pipeline.js.map +0 -1
  152. package/dist/es/web-csv-toolbox.js +0 -13
  153. package/dist/es/web-csv-toolbox.js.map +0 -1
  154. package/dist/types/Lexer.d.ts +0 -27
  155. package/dist/types/Lexer.test.d.ts +0 -1
  156. package/dist/types/LexerTransformer.d.ts +0 -37
  157. package/dist/types/LexerTransformer.test.d.ts +0 -1
  158. package/dist/types/RecordAssembler.d.ts +0 -8
  159. package/dist/types/RecordAssemblerTransformer.d.ts +0 -50
  160. package/dist/types/assertCommonOptions.d.ts +0 -22
  161. package/dist/types/common/constants.d.ts +0 -15
  162. package/dist/types/common/errors.d.ts +0 -34
  163. package/dist/types/common/types.d.ts +0 -228
  164. package/dist/types/commonParseErrorHandling.d.ts +0 -8
  165. package/dist/types/constants.d.ts +0 -11
  166. package/dist/types/escapeField.d.ts +0 -14
  167. package/dist/types/getOptionsFromResponse.d.ts +0 -11
  168. package/dist/types/loadWASM.d.ts +0 -19
  169. package/dist/types/loadWASM.web.d.ts +0 -19
  170. package/dist/types/parse.d.ts +0 -183
  171. package/dist/types/parseBinary.d.ts +0 -114
  172. package/dist/types/parseBinaryToArraySync.d.ts +0 -3
  173. package/dist/types/parseBinaryToArraySync.test.d.ts +0 -1
  174. package/dist/types/parseBinaryToIterableIterator.d.ts +0 -11
  175. package/dist/types/parseBinaryToStream.d.ts +0 -3
  176. package/dist/types/parseResponse.d.ts +0 -81
  177. package/dist/types/parseResponseToStream.d.ts +0 -3
  178. package/dist/types/parseString.d.ts +0 -121
  179. package/dist/types/parseStringStream.d.ts +0 -99
  180. package/dist/types/parseStringStreamToStream.d.ts +0 -3
  181. package/dist/types/parseStringToArraySync.d.ts +0 -3
  182. package/dist/types/parseStringToArraySyncWASM.d.ts +0 -38
  183. package/dist/types/parseStringToIterableIterator.d.ts +0 -3
  184. package/dist/types/parseStringToStream.d.ts +0 -3
  185. package/dist/types/parseUint8ArrayStream.d.ts +0 -95
  186. package/dist/types/parseUint8ArrayStreamToStream.d.ts +0 -3
  187. package/dist/types/utils/SingleValueReadableStream.d.ts +0 -3
  188. package/dist/types/utils/convertBinaryToString.d.ts +0 -12
  189. package/dist/types/utils/convertIterableIteratorToAsync.d.ts +0 -1
  190. package/dist/types/utils/convertStreamToAsyncIterableIterator.d.ts +0 -1
  191. package/dist/types/utils/convertThisAsyncIterableIteratorToArray.d.ts +0 -1
  192. package/dist/types/utils/escapeRegExp.d.ts +0 -8
  193. package/dist/types/utils/occurrences.d.ts +0 -7
  194. package/dist/types/utils/parseMime.d.ts +0 -7
  195. package/dist/types/utils/pipeline.d.ts +0 -3
  196. package/dist/types/web-csv-toolbox.d.ts +0 -13
  197. package/dist/web-csv-toolbox.umd.cjs +0 -2
  198. package/dist/web-csv-toolbox.umd.cjs.map +0 -1
  199. package/dist/web_csv_toolbox_wasm_bg.wasm +0 -0
@@ -1,183 +0,0 @@
1
- import { CSVBinary, CSVRecord, CSVString, ParseBinaryOptions, ParseOptions } from './common/types.ts';
2
-
3
- /**
4
- * Parse CSV to records.
5
- *
6
- * {@link !String}, {@link !ReadableStream}<string | {@link !Uint8Array}> and {@link !Response} are supported.
7
- *
8
- *
9
- * @typeParam Header Header type like `['name', 'age']`.
10
- *
11
- * @param csv CSV string to parse.
12
- * @param options Parsing options for CSV string parsing.
13
- * @returns Async iterable iterator of records.
14
- *
15
- * If you want array of records, use {@link parse.toArray} function.
16
- * @category High-level API
17
- *
18
- * @remarks
19
- * {@link parseString}, {@link parseBinary}, {@link parseUint8ArrayStream},
20
- * {@link parseStringStream} and {@link parseResponse} are used internally.
21
- *
22
- * If you known the type of the CSV, it performs better to use them directly.
23
- *
24
- * | If you want to parse a... | Use... | Options... |
25
- * | -------------------------------------------- | ----------------------------- | -------------------------- |
26
- * | {@link !String} | {@link parseString} | {@link ParseOptions} |
27
- * | {@link !ReadableStream}<{@link !String}> | {@link parseStringStream} | {@link ParseOptions} |
28
- * | {@link !Uint8Array} \| {@link !ArrayBuffer} | {@link parseBinary} | {@link ParseBinaryOptions} |
29
- * | {@link !ReadableStream}<{@link !Uint8Array}> | {@link parseUint8ArrayStream} | {@link ParseBinaryOptions} |
30
- * | {@link !Response} | {@link parseResponse} | {@link ParseBinaryOptions} |
31
- *
32
- * @example Parsing CSV files from strings
33
- *
34
- * ```ts
35
- * import { parse } from 'web-csv-toolbox';
36
- *
37
- * const csv = `name,age
38
- * Alice,42
39
- * Bob,69`;
40
- *
41
- * for await (const record of parse(csv)) {
42
- * console.log(record);
43
- * }
44
- * // Prints:
45
- * // { name: 'Alice', age: '42' }
46
- * // { name: 'Bob', age: '69' }
47
- * ```
48
- *
49
- * @example Parsing CSV files from streams
50
- *
51
- * ```ts
52
- * import { parse } from 'web-csv-toolbox';
53
- *
54
- * const csv = `name,age
55
- * Alice,42
56
- * Bob,69`;
57
- *
58
- * const stream = new ReadableStream({
59
- * start(controller) {
60
- * controller.enqueue(csv);
61
- * controller.close();
62
- * }
63
- * });
64
- *
65
- * for await (const record of parse(stream)) {
66
- * console.log(record);
67
- * }
68
- * // Prints:
69
- * // { name: 'Alice', age: '42' }
70
- * // { name: 'Bob', age: '69' }
71
- * ```
72
- *
73
- *
74
- * @example Parsing CSV files with headers
75
- *
76
- * ```ts
77
- * import { parse } from 'web-csv-toolbox';
78
- *
79
- * // This CSV has no header.
80
- * const csv = `Alice,42
81
- * Bob,69`;
82
- *
83
- * for await (const record of parse(csv, { header: ['name', 'age'] })) {
84
- * console.log(record);
85
- * }
86
- * // Prints:
87
- * // { name: 'Alice', age: '42' }
88
- * // { name: 'Bob', age: '69' }
89
- * ```
90
- *
91
- * @example Parsing CSV files with different delimiters characters
92
- *
93
- * ```ts
94
- * import { parse } from 'web-csv-toolbox';
95
- *
96
- * const csv = `name\tage
97
- * Alice\t42
98
- * Bob\t69`;
99
- *
100
- * for await (const record of parse(csv, { delimiter: '\t' })) {
101
- * console.log(record);
102
- * }
103
- * // Prints:
104
- * // { name: 'Alice', age: '42' }
105
- * // { name: 'Bob', age: '69' }
106
- * ```
107
- */
108
- export declare function parse<Header extends ReadonlyArray<string>>(csv: CSVString, options?: ParseOptions<Header>): AsyncIterableIterator<CSVRecord<Header>>;
109
- /**
110
- * Parse CSV binary to records.
111
- *
112
- * @param csv CSV binary to parse.
113
- * @param options Parsing options for CSV binary parsing.
114
- *
115
- * @example Parsing CSV files from responses
116
- *
117
- * ```ts
118
- * import { parse } from 'web-csv-toolbox';
119
- *
120
- * // This CSV data is not gzipped and encoded in utf-8.
121
- * const response = await fetch('https://example.com/data.csv');
122
- *
123
- * for await (const record of parse(response)) {
124
- * // ...
125
- * }
126
- * ```
127
- *
128
- * @example Parsing CSV files with options spcialized for binary
129
- *
130
- * ```ts
131
- * import { parse } from 'web-csv-toolbox';
132
- *
133
- * // This CSV data is gzipped and encoded in shift-jis and has BOM.
134
- * const response = await fetch('https://example.com/data.csv.gz');
135
- *
136
- * for await (const record of parse(response, {
137
- * charset: 'shift-jis',
138
- * ignoreBOM: true,
139
- * decomposition: 'gzip',
140
- * })) {
141
- * // ...
142
- * }
143
- * ```
144
- */
145
- export declare function parse<Header extends ReadonlyArray<string>>(csv: CSVBinary, options?: ParseBinaryOptions<Header>): AsyncIterableIterator<CSVRecord<Header>>;
146
- export declare namespace parse {
147
- /**
148
- * Parse CSV string to array of records,
149
- * ideal for smaller data sets.
150
- *
151
- * @example Parse a CSV as array of records
152
- *
153
- * ```ts
154
- * import { parse } from 'web-csv-toolbox';
155
- *
156
- * const csv = `name,age
157
- * Alice,42
158
- * Bob,69`;
159
- *
160
- * const records = await parse.toArray(csv);
161
- * console.log(records);
162
- * // Prints:
163
- * // [ { name: 'Alice', age: '42' }, { name: 'Bob', age: '69' } ]
164
- * ```
165
- */
166
- function toArray<Header extends ReadonlyArray<string>>(csv: CSVString, options?: ParseOptions<Header>): Promise<CSVRecord<Header>[]>;
167
- /**
168
- * Parse CSV string to array of records,
169
- * ideal for smaller data sets.
170
- *
171
- * @example Parse a CSV as array of records
172
- *
173
- * ```ts
174
- * import { parse } from 'web-csv-toolbox';
175
- *
176
- * const response = await fetch('https://example.com/data.csv');
177
- *
178
- * const records = await parse.toArray(response);
179
- * console.log(records);
180
- * ```
181
- */
182
- function toArray<Header extends ReadonlyArray<string>>(csv: CSVBinary, options?: ParseBinaryOptions<Header>): Promise<CSVRecord<Header>[]>;
183
- }
@@ -1,114 +0,0 @@
1
- import { CSVRecord, ParseBinaryOptions } from './common/types.ts';
2
-
3
- /**
4
- * Parse a binary from an {@link !Uint8Array}.
5
- *
6
- * @category Middle-level API
7
- *
8
- * @param bytes CSV bytes to parse.
9
- * @param options Parsing options
10
- * @returns Async iterable iterator of records.
11
- *
12
- * @example Parsing CSV binary
13
- *
14
- * ```ts
15
- * import { parseUint8Array } from 'web-csv-toolbox';
16
- *
17
- * const csv = Uint8Array.from([
18
- * // ...
19
- * ]);
20
- *
21
- * for await (const record of parseUint8Array(csv)) {
22
- * console.log(record);
23
- * }
24
- * ```
25
- */
26
- export declare function parseBinary<Header extends ReadonlyArray<string>>(bytes: Uint8Array | ArrayBuffer, options?: ParseBinaryOptions<Header>): AsyncIterableIterator<CSVRecord<Header>>;
27
- export declare namespace parseBinary {
28
- /**
29
- * Parse a binary from an {@link !Uint8Array} to an array of records.
30
- *
31
- * @param bytes CSV bytes to parse.
32
- * @param options Parsing options
33
- * @returns Array of records
34
- *
35
- * @example
36
- * ```ts
37
- * import { parseUint8Array } from 'web-csv-toolbox';
38
- *
39
- * const csv = Uint8Array.from([
40
- * // ...
41
- * ]);
42
- *
43
- * const records = await parseUint8Array.toArray(csv);
44
- * ```
45
- */
46
- function toArray<Header extends ReadonlyArray<string>>(bytes: Uint8Array | ArrayBuffer, options?: ParseBinaryOptions<Header>): Promise<CSVRecord<Header>[]>;
47
- /**
48
- * Parse a binary from an {@link !Uint8Array} to an array of records.
49
- *
50
- * @param bytes CSV bytes to parse.
51
- * @param options Parsing options
52
- * @returns Array of records
53
- * @example
54
- *
55
- * ```ts
56
- * import { parseUint8Array } from 'web-csv-toolbox';
57
- *
58
- * const csv = Uint8Array.from([
59
- * // ...
60
- * ]);
61
- *
62
- * const records = parseUint8Array.toArraySync(csv);
63
- * ```
64
- */
65
- function toArraySync<Header extends ReadonlyArray<string>>(bytes: Uint8Array | ArrayBuffer, options?: ParseBinaryOptions<Header>): CSVRecord<Header>[];
66
- /**
67
- * Parse a binary from an {@link !Uint8Array} to an iterable iterator of records.
68
- *
69
- * @param bytes CSV bytes to parse.
70
- * @param options Parsing options
71
- * @returns Async iterable iterator of records.
72
- * @example
73
- * ```ts
74
- * import { parseUint8Array } from 'web-csv-toolbox';
75
- *
76
- * const csv = Uint8Array.from([
77
- * // ...
78
- * ]);
79
- *
80
- * for (const record of parseUint8Array.toIterableIterator(csv)) {
81
- * console.log(record);
82
- * }
83
- * ```
84
- */
85
- function toIterableIterator<Header extends ReadonlyArray<string>>(bytes: Uint8Array, options?: ParseBinaryOptions<Header>): IterableIterator<CSVRecord<Header>>;
86
- /**
87
- * Parse a binary from an {@link !Uint8Array} to a stream of records.
88
- *
89
- * @param bytes CSV bytes to parse.
90
- * @param options Parsing options
91
- * @returns Stream of records.
92
- *
93
- * @example
94
- *
95
- * ```ts
96
- * import { parseUint8Array } from 'web-csv-toolbox';
97
- *
98
- * const csv = Uint8Array.from([
99
- * // ...
100
- * ]);
101
- *
102
- * const stream = parseUint8Array.toStream(csv);
103
- *
104
- * await stream.pipeTo(
105
- * new WritableStream({
106
- * write(record) {
107
- * console.log(record);
108
- * },
109
- * }),
110
- * );
111
- * ```
112
- */
113
- function toStream<Header extends ReadonlyArray<string>>(bytes: Uint8Array, options?: ParseBinaryOptions<Header>): ReadableStream<CSVRecord<Header>>;
114
- }
@@ -1,3 +0,0 @@
1
- import { CSVRecord, ParseBinaryOptions } from './common/types.ts';
2
-
3
- export declare function parseBinaryToArraySync<Header extends ReadonlyArray<string>>(binary: Uint8Array | ArrayBuffer, options?: ParseBinaryOptions<Header>): CSVRecord<Header>[];
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { CSVRecord, ParseBinaryOptions } from './common/types.ts';
2
-
3
- /**
4
- * Parses the given binary data into an iterable iterator of CSV records.
5
- *
6
- * @param binary - The binary data to parse.
7
- * @param options - The parse options.
8
- * @returns An iterable iterator of CSV records.
9
- * @throws {ParseError} When an error occurs while parsing the CSV data.
10
- */
11
- export declare function parseBinaryToIterableIterator<Header extends ReadonlyArray<string>>(binary: Uint8Array | ArrayBuffer, options?: ParseBinaryOptions<Header>): IterableIterator<CSVRecord<Header>>;
@@ -1,3 +0,0 @@
1
- import { CSVRecord, ParseBinaryOptions } from './common/types.ts';
2
-
3
- export declare function parseBinaryToStream<Header extends ReadonlyArray<string>>(binary: Uint8Array | ArrayBuffer, options?: ParseBinaryOptions<Header>): ReadableStream<CSVRecord<Header>>;
@@ -1,81 +0,0 @@
1
- import { CSVRecord, ParseOptions } from './common/types.ts';
2
-
3
- /**
4
- * Parse HTTP Response what contains CSV to records,
5
- * ideal for smaller data sets.
6
- *
7
- * @remarks
8
- * This function automatically treats response headers.
9
- *
10
- * - If `Content-Type` header is not set, it assumes `text/csv`.
11
- * - If `Content-Type` header is not `text/csv`, it throws an error.
12
- * - If `Content-Type` header has charset parameter, it uses it for decoding.
13
- * - If `Content-Encoding` header is set, it decompresses the response.
14
- * - Should there be any conflicting information between the header and the options, the option's value will take precedence.
15
- *
16
- * @category Middle-level API
17
- * @param response
18
- * @param options
19
- * @returns Async iterable iterator of records.
20
- *
21
- * If you want array of records, use {@link parseResponse.toArray} function.
22
- *
23
- * @example Parsing CSV Response
24
- *
25
- * ```ts
26
- * import { parseResponse } from 'web-csv-toolbox';
27
- *
28
- * const response = await fetch('https://example.com/data.csv');
29
- *
30
- * for await (const record of parseResponse(response)) {
31
- * console.log(record);
32
- * }
33
- * ```
34
- */
35
- export declare function parseResponse<Header extends ReadonlyArray<string>>(response: Response, options?: ParseOptions<Header>): AsyncIterableIterator<CSVRecord<Header>>;
36
- export declare namespace parseResponse {
37
- /**
38
- * Parse CSV Response to array of records.
39
- *
40
- * @returns Array of records
41
- *
42
- * @example Parsing CSV Response
43
- *
44
- * ```ts
45
- * import { parseResponse } from 'web-csv-toolbox';
46
- *
47
- * const response = await fetch('https://example.com/data.csv');
48
- *
49
- * const records = await parseResponse.toArray(response);
50
- * console.log(records);
51
- * ```
52
- */
53
- function toArray<Header extends ReadonlyArray<string>>(response: Response, options?: ParseOptions<Header>): Promise<CSVRecord<Header>[]>;
54
- /**
55
- * Parse CSV Response to stream of records.
56
- *
57
- * @param response Response to parse
58
- * @returns Stream of records
59
- *
60
- * @example Parsing CSV Response
61
- *
62
- * ```ts
63
- * import { parseResponse } from 'web-csv-toolbox';
64
- *
65
- * const response = await fetch('https://example.com/data.csv');
66
- *
67
- * await parseResponse.toStream(response)
68
- * .pipeTo(
69
- * new WritableStream({
70
- * write(record) {
71
- * console.log(record);
72
- * },
73
- * }),
74
- * );
75
- * // Prints:
76
- * // { name: 'Alice', age: '42' }
77
- * // { name: 'Bob', age: '69' }
78
- * ```
79
- */
80
- function toStream<Header extends ReadonlyArray<string>>(response: Response, options?: ParseOptions<Header>): ReadableStream<CSVRecord<Header>[]>;
81
- }
@@ -1,3 +0,0 @@
1
- import { CSVRecord, ParseBinaryOptions } from './common/types.ts';
2
-
3
- export declare function parseResponseToStream<Header extends ReadonlyArray<string>>(response: Response, options?: ParseBinaryOptions<Header>): ReadableStream<CSVRecord<Header>>;
@@ -1,121 +0,0 @@
1
- import { CSVRecord, ParseOptions } from './common/types.ts';
2
-
3
- /**
4
- * Parse CSV string to records.
5
- *
6
- * @category Middle-level API
7
- * @param csv CSV string to parse
8
- * @param options Parsing options. See {@link ParseOptions}.
9
- * @returns Async iterable iterator of records.
10
- *
11
- * If you want array of records, use {@link parseString.toArray} function.
12
- * @example Parsing CSV files from strings
13
- *
14
- * ```ts
15
- * import { parseString } from 'web-csv-toolbox';
16
- *
17
- * const csv = `name,age
18
- * Alice,42
19
- * Bob,69`;
20
- *
21
- * for await (const record of parseString(csv)) {
22
- * console.log(record);
23
- * }
24
- * // Prints:
25
- * // { name: 'Alice', age: '42' }
26
- * // { name: 'Bob', age: '69' }
27
- * ```
28
- */
29
- export declare function parseString<Header extends ReadonlyArray<string>>(csv: string, options?: ParseOptions<Header>): AsyncIterableIterator<CSVRecord<Header>>;
30
- export declare namespace parseString {
31
- /**
32
- * Parse CSV string to records.
33
- *
34
- * @returns Array of records
35
- *
36
- * @example
37
- * ```ts
38
- * import { parseString } from 'web-csv-toolbox';
39
- *
40
- * const csv = `name,age
41
- * Alice,42
42
- * Bob,69`;
43
- *
44
- * const records = await parseString.toArray(csv);
45
- * console.log(records);
46
- * // Prints:
47
- * // [ { name: 'Alice', age: '42' }, { name: 'Bob', age: '69' } ]
48
- * ```
49
- */
50
- function toArray<Header extends ReadonlyArray<string>>(csv: string, options?: ParseOptions<Header>): Promise<CSVRecord<Header>[]>;
51
- /**
52
- * Parse CSV string to records.
53
- *
54
- * @returns Array of records
55
- *
56
- * @example
57
- *
58
- * ```ts
59
- * import { parseString } from 'web-csv-toolbox';
60
- *
61
- * const csv = `name,age
62
- * Alice,42
63
- * Bob,69`;
64
- *
65
- * const records = parseString.toArraySync(csv);
66
- * console.log(records);
67
- * // Prints:
68
- * // [ { name: 'Alice', age: '42' }, { name: 'Bob', age: '69' } ]
69
- * ```
70
- */
71
- function toArraySync<Header extends ReadonlyArray<string>>(csv: string, options?: ParseOptions<Header>): CSVRecord<Header>[];
72
- /**
73
- * Parse CSV string to records.
74
- *
75
- * @returns Async iterable iterator of records
76
- *
77
- * @example
78
- * ```ts
79
- * import { parseString } from 'web-csv-toolbox';
80
- *
81
- * const csv = `name,age
82
- * Alice,42
83
- * Bob,69`;
84
- *
85
- * for (const record of parseString.toIterableIterator(csv)) {
86
- * console.log(record);
87
- * }
88
- * // Prints:
89
- * // { name: 'Alice', age: '42' }
90
- * // { name: 'Bob', age: '69' }
91
- * ```
92
- */
93
- function toIterableIterator<Header extends ReadonlyArray<string>>(csv: string, options?: ParseOptions<Header>): IterableIterator<CSVRecord<Header>>;
94
- /**
95
- * Parse CSV string to records.
96
- *
97
- * @returns Readable stream of records
98
- *
99
- * @example
100
- * ```ts
101
- * import { parseString } from 'web-csv-toolbox';
102
- *
103
- * const csv = `name,age
104
- * Alice,42
105
- * Bob,69`;
106
- *
107
- * await parseString.toStream(csv)
108
- * .pipeTo(
109
- * new WritableStream({
110
- * write(record) {
111
- * console.log(record);
112
- * },
113
- * }),
114
- * );
115
- * // Prints:
116
- * // { name: 'Alice', age: '42' }
117
- * // { name: 'Bob', age: '69' }
118
- * ```
119
- */
120
- function toStream<Header extends ReadonlyArray<string>>(csv: string, options?: ParseOptions<Header>): ReadableStream<CSVRecord<Header>>;
121
- }
@@ -1,99 +0,0 @@
1
- import { CSVRecord, ParseOptions } from './common/types.ts';
2
-
3
- /**
4
- * Parse CSV string stream to records.
5
- *
6
- * @category Middle-level API
7
- * @param stream CSV string stream to parse
8
- * @param options Parsing options.
9
- * @returns Async iterable iterator of records.
10
- *
11
- * If you want array of records, use {@link parseStringStream.toArray} function.
12
- *
13
- * @example Parsing CSV files from strings
14
- *
15
- * ```ts
16
- * import { parseStringStream } from 'web-csv-toolbox';
17
- *
18
- * const csv = `name,age
19
- * Alice,42
20
- * Bob,69`;
21
- *
22
- * const stream = new ReadableStream({
23
- * start(controller) {
24
- * controller.enqueue(csv);
25
- * controller.close();
26
- * },
27
- * });
28
- *
29
- * for await (const record of parseStringStream(csv)) {
30
- * console.log(record);
31
- * }
32
- * // Prints:
33
- * // { name: 'Alice', age: '42' }
34
- * // { name: 'Bob', age: '69' }
35
- * ```
36
- */
37
- export declare function parseStringStream<Header extends ReadonlyArray<string>>(stream: ReadableStream<string>, options?: ParseOptions<Header>): AsyncIterableIterator<CSVRecord<Header>>;
38
- export declare namespace parseStringStream {
39
- /**
40
- * Parse CSV string stream to records.
41
- *
42
- * @returns Array of records
43
- *
44
- * @example
45
- *
46
- * ```ts
47
- * import { parseStringStream } from 'web-csv-toolbox';
48
- *
49
- * const csv = `name,age
50
- * Alice,42
51
- * Bob,69`;
52
- *
53
- * const stream = new ReadableStream({
54
- * start(controller) {
55
- * controller.enqueue(csv);
56
- * controller.close();
57
- * },
58
- * });
59
- *
60
- * const records = await parseStringStream.toArray(stream);
61
- * console.log(records);
62
- * // Prints:
63
- * // [ { name: 'Alice', age: '42' }, { name: 'Bob', age: '69' } ]
64
- * ```
65
- */
66
- function toArray<Header extends ReadonlyArray<string>>(stream: ReadableStream<string>, options?: ParseOptions<Header>): Promise<CSVRecord<Header>[]>;
67
- /**
68
- * Parse CSV string stream to records.
69
- *
70
- * @returns Array of records
71
- *
72
- * @example
73
- *
74
- * ```ts
75
- * import { parseStringStream } from 'web-csv-toolbox';
76
- *
77
- * const csv = `name,age
78
- * Alice,42
79
- * Bob,69`;
80
- *
81
- * const stream = new ReadableStream({
82
- * start(controller) {
83
- * controller.enqueue(csv);
84
- * controller.close();
85
- * },
86
- * });
87
- *
88
- * await parseStringStream.toStream(stream)
89
- * .pipeTo(
90
- * new WritableStream({
91
- * write(record) {
92
- * console.log(record);
93
- * },
94
- * }),
95
- * );
96
- * ```
97
- */
98
- function toStream<Header extends ReadonlyArray<string>>(stream: ReadableStream<string>, options?: ParseOptions<Header>): ReadableStream<CSVRecord<Header>>;
99
- }
@@ -1,3 +0,0 @@
1
- import { CSVRecord, ParseOptions } from './common/types.ts';
2
-
3
- export declare function parseStringStreamToStream<Header extends ReadonlyArray<string>>(stream: ReadableStream<string>, options?: ParseOptions<Header>): ReadableStream<CSVRecord<Header>>;
@@ -1,3 +0,0 @@
1
- import { CSVRecord, ParseOptions } from './common/types.ts';
2
-
3
- export declare function parseStringToArraySync<Header extends ReadonlyArray<string>>(csv: string, options?: ParseOptions<Header>): CSVRecord<Header>[];
@@ -1,38 +0,0 @@
1
- import { CSVRecord, CommonOptions } from './common/types.ts';
2
-
3
- /**
4
- * Parse CSV string to record of arrays.
5
- *
6
- * @param csv CSV string
7
- * @param options Parse options
8
- * @returns Record of arrays
9
- *
10
- * @remarks
11
- * This function uses WebAssembly to parse CSV string.
12
- * Before calling this function, you must call {@link loadWASM} function.
13
- *
14
- * This function only supports UTF-8 string.
15
- * If you pass a string that is not UTF-8, like UTF-16, it throws an error.
16
- * This function only supports double quote as quotation.
17
- * So, `options.quotation` must be `"` (double quote). Otherwise, it throws an error.
18
- *
19
- * And this function only supports single character as delimiter.
20
- * So, `options.delimiter` must be a single character. Otherwise, it throws an error.
21
- *
22
- * @example
23
- *
24
- * ```ts
25
- * import { loadWASM, parseStringWASM } from "web-csv-toolbox";
26
- *
27
- * await loadWASM();
28
- *
29
- * const csv = "a,b,c\n1,2,3";
30
- *
31
- * const result = parseStringToArraySyncWASM(csv);
32
- * console.log(result);
33
- * // Prints:
34
- * // [{ a: "1", b: "2", c: "3" }]
35
- * ```
36
- * @beta
37
- */
38
- export declare function parseStringToArraySyncWASM<Header extends readonly string[]>(csv: string, options?: CommonOptions): CSVRecord<Header>[];
@@ -1,3 +0,0 @@
1
- import { CSVRecord, ParseOptions } from './common/types.ts';
2
-
3
- export declare function parseStringToIterableIterator<Header extends ReadonlyArray<string>>(csv: string, options?: ParseOptions<Header>): IterableIterator<CSVRecord<Header>>;
@@ -1,3 +0,0 @@
1
- import { CSVRecord, ParseOptions } from './common/types.ts';
2
-
3
- export declare function parseStringToStream<Header extends ReadonlyArray<string>>(csv: string, options?: ParseOptions<Header>): ReadableStream<CSVRecord<Header>>;