web-csv-toolbox 0.10.3-next-10321180d04c1d67f731d55f6c6190691c0d7ba6 → 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,11 +0,0 @@
1
- async function* convertStreamToAsyncIterableIterator(stream) {
2
- const reader = stream.getReader();
3
- while (true) {
4
- const { done, value } = await reader.read();
5
- if (done) break;
6
- yield value;
7
- }
8
- }
9
-
10
- export { convertStreamToAsyncIterableIterator };
11
- //# sourceMappingURL=convertStreamToAsyncIterableIterator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertStreamToAsyncIterableIterator.js","sources":["../../../src/utils/convertStreamToAsyncIterableIterator.ts"],"sourcesContent":["export async function* convertStreamToAsyncIterableIterator<T>(\n stream: ReadableStream<T>,\n): AsyncIterableIterator<T> {\n const reader = stream.getReader();\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n yield value;\n }\n}\n"],"names":[],"mappings":"AAAA,gBAAuB,qCACrB,MAC0B,EAAA;AAC1B,EAAM,MAAA,MAAA,GAAS,OAAO,SAAU,EAAA,CAAA;AAChC,EAAA,OAAO,IAAM,EAAA;AACX,IAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAU,GAAA,MAAM,OAAO,IAAK,EAAA,CAAA;AAC1C,IAAA,IAAI,IAAM,EAAA,MAAA;AACV,IAAM,MAAA,KAAA,CAAA;AAAA,GACR;AACF;;;;"}
@@ -1,10 +0,0 @@
1
- async function convertThisAsyncIterableIteratorToArray(...args) {
2
- const rows = [];
3
- for await (const row of this(...args)) {
4
- rows.push(row);
5
- }
6
- return rows;
7
- }
8
-
9
- export { convertThisAsyncIterableIteratorToArray };
10
- //# sourceMappingURL=convertThisAsyncIterableIteratorToArray.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertThisAsyncIterableIteratorToArray.js","sources":["../../../src/utils/convertThisAsyncIterableIteratorToArray.ts"],"sourcesContent":["export async function convertThisAsyncIterableIteratorToArray<\n O,\n T extends (...args: any[]) => AsyncGenerator<O>,\n>(this: T, ...args: Parameters<T>): Promise<O[]> {\n const rows: O[] = [];\n for await (const row of this(...args)) {\n rows.push(row);\n }\n return rows;\n}\n"],"names":[],"mappings":"AAAA,eAAsB,2CAGR,IAAmC,EAAA;AAC/C,EAAA,MAAM,OAAY,EAAC,CAAA;AACnB,EAAA,WAAA,MAAiB,GAAO,IAAA,IAAA,CAAK,GAAG,IAAI,CAAG,EAAA;AACrC,IAAA,IAAA,CAAK,KAAK,GAAG,CAAA,CAAA;AAAA,GACf;AACA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
@@ -1,6 +0,0 @@
1
- function escapeRegExp(v) {
2
- return v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3
- }
4
-
5
- export { escapeRegExp };
6
- //# sourceMappingURL=escapeRegExp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escapeRegExp.js","sources":["../../../src/utils/escapeRegExp.ts"],"sourcesContent":["/**\n * Escape a string for use in a regular expression.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping Regular expressions#Escaping | MDN}\n * @param v string to escape\n * @returns escaped string\n */\nexport function escapeRegExp(v: string) {\n return v.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n"],"names":[],"mappings":"AAOO,SAAS,aAAa,CAAW,EAAA;AACtC,EAAO,OAAA,CAAA,CAAE,OAAQ,CAAA,qBAAA,EAAuB,MAAM,CAAA,CAAA;AAChD;;;;"}
@@ -1,15 +0,0 @@
1
- function parseMime(contentType) {
2
- const [type, ...parameters] = contentType.split(";");
3
- const result = {
4
- type: type.trim(),
5
- parameters: {}
6
- };
7
- for (const paramator of parameters) {
8
- const [key, value] = paramator.split("=");
9
- result.parameters[key.trim()] = value.trim();
10
- }
11
- return result;
12
- }
13
-
14
- export { parseMime };
15
- //# sourceMappingURL=parseMime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseMime.js","sources":["../../../src/utils/parseMime.ts"],"sourcesContent":["export interface ParseMimeResult {\n type: string;\n parameters: {\n [key: string]: string;\n };\n}\n\nexport function parseMime(contentType: string) {\n const [type, ...parameters] = contentType.split(\";\");\n const result: ParseMimeResult = {\n type: type.trim(),\n parameters: {},\n };\n for (const paramator of parameters) {\n const [key, value] = paramator.split(\"=\");\n result.parameters[key.trim()] = value.trim();\n }\n return result;\n}\n"],"names":[],"mappings":"AAOO,SAAS,UAAU,WAAqB,EAAA;AAC7C,EAAA,MAAM,CAAC,IAAM,EAAA,GAAG,UAAU,CAAI,GAAA,WAAA,CAAY,MAAM,GAAG,CAAA,CAAA;AACnD,EAAA,MAAM,MAA0B,GAAA;AAAA,IAC9B,IAAA,EAAM,KAAK,IAAK,EAAA;AAAA,IAChB,YAAY,EAAC;AAAA,GACf,CAAA;AACA,EAAA,KAAA,MAAW,aAAa,UAAY,EAAA;AAClC,IAAA,MAAM,CAAC,GAAK,EAAA,KAAK,CAAI,GAAA,SAAA,CAAU,MAAM,GAAG,CAAA,CAAA;AACxC,IAAA,MAAA,CAAO,WAAW,GAAI,CAAA,IAAA,EAAM,CAAA,GAAI,MAAM,IAAK,EAAA,CAAA;AAAA,GAC7C;AACA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -1,18 +0,0 @@
1
- function pipeline(stream, ...transformers) {
2
- return new ReadableStream({
3
- start: (controller) => {
4
- (() => transformers.reduce(
5
- (stream2, transformer) => stream2.pipeThrough(transformer),
6
- stream
7
- ).pipeTo(
8
- new WritableStream({
9
- write: (v) => controller.enqueue(v),
10
- close: () => controller.close()
11
- })
12
- ).catch((error) => controller.error(error)))();
13
- }
14
- });
15
- }
16
-
17
- export { pipeline };
18
- //# sourceMappingURL=pipeline.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipeline.js","sources":["../../../src/utils/pipeline.ts"],"sourcesContent":["export function pipeline<I, T, O>(\n stream: ReadableStream<I>,\n transformer1: TransformStream<I, T>,\n transformer2: TransformStream<T, O>,\n): ReadableStream<O>;\nexport function pipeline<I, T1, T2, O>(\n stream: ReadableStream<I>,\n transformer1: TransformStream<I, T1>,\n transformer2: TransformStream<T1, T2>,\n transformer3: TransformStream<T2, O>,\n): ReadableStream<O>;\nexport function pipeline<I, T1, T2, T3, O>(\n stream: ReadableStream<I>,\n transformer1: TransformStream<I, T1>,\n transformer2: TransformStream<T1, T2>,\n transformer3: TransformStream<T2, T3>,\n transformer4: TransformStream<T3, O>,\n): ReadableStream<O>;\nexport function pipeline<I, O>(\n stream: ReadableStream<I>,\n ...transformers: TransformStream[]\n): ReadableStream<O> {\n return new ReadableStream({\n start: (controller) => {\n (() =>\n transformers\n .reduce<ReadableStream>(\n (stream, transformer) => stream.pipeThrough(transformer),\n stream,\n )\n .pipeTo(\n new WritableStream({\n write: (v) => controller.enqueue(v),\n close: () => controller.close(),\n }),\n )\n .catch((error) => controller.error(error)))();\n },\n });\n}\n"],"names":["stream"],"mappings":"AAkBgB,SAAA,QAAA,CACd,WACG,YACgB,EAAA;AACnB,EAAA,OAAO,IAAI,cAAe,CAAA;AAAA,IACxB,KAAA,EAAO,CAAC,UAAe,KAAA;AACrB,MAAA,CAAC,MACC,YACG,CAAA,MAAA;AAAA,QACC,CAACA,OAAAA,EAAQ,WAAgBA,KAAAA,OAAAA,CAAO,YAAY,WAAW,CAAA;AAAA,QACvD,MAAA;AAAA,OAED,CAAA,MAAA;AAAA,QACC,IAAI,cAAe,CAAA;AAAA,UACjB,KAAO,EAAA,CAAC,CAAM,KAAA,UAAA,CAAW,QAAQ,CAAC,CAAA;AAAA,UAClC,KAAA,EAAO,MAAM,UAAA,CAAW,KAAM,EAAA;AAAA,SAC/B,CAAA;AAAA,OACH,CACC,MAAM,CAAC,KAAA,KAAU,WAAW,KAAM,CAAA,KAAK,CAAC,CAAG,GAAA,CAAA;AAAA,KAClD;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -1,13 +0,0 @@
1
- export { Field, FieldDelimiter, RecordDelimiter } from './common/constants.js';
2
- export { InvalidOptionError, ParseError } from './common/errors.js';
3
- export { LexerTransformer } from './LexerTransformer.js';
4
- export { loadWASM } from './loadWASM.js';
5
- export { parse } from './parse.js';
6
- export { parseBinary } from './parseBinary.js';
7
- export { parseResponse } from './parseResponse.js';
8
- export { parseString } from './parseString.js';
9
- export { parseStringStream } from './parseStringStream.js';
10
- export { parseStringToArraySyncWASM } from './parseStringToArraySyncWASM.js';
11
- export { parseUint8ArrayStream } from './parseUint8ArrayStream.js';
12
- export { RecordAssemblerTransformer } from './RecordAssemblerTransformer.js';
13
- //# sourceMappingURL=web-csv-toolbox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-csv-toolbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1,27 +0,0 @@
1
- import { CommonOptions, Token } from './common/types.ts';
2
-
3
- /**
4
- * CSV Lexer.
5
- *
6
- * Lexter tokenizes CSV data into fields and records.
7
- */
8
- export declare class Lexer {
9
- #private;
10
- /**
11
- * Constructs a new Lexer instance.
12
- * @param options - The common options for the lexer.
13
- */
14
- constructor({ delimiter, quotation, }?: CommonOptions);
15
- /**
16
- * Lexes the given chunk of CSV data.
17
- * @param chunk - The chunk of CSV data to be lexed.
18
- * @param buffering - Indicates whether the lexer is buffering or not.
19
- * @returns An iterable iterator of tokens.
20
- */
21
- lex(chunk: string | null, buffering?: boolean): IterableIterator<Token>;
22
- /**
23
- * Flushes the lexer and returns any remaining tokens.
24
- * @returns An array of tokens.
25
- */
26
- flush(): Token[];
27
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- import { Lexer } from './Lexer.ts';
2
- import { CommonOptions, Token } from './common/types.ts';
3
-
4
- /**
5
- * A transform stream that converts a stream of tokens into a stream of rows.
6
- *
7
- * @category Low-level API
8
- *
9
- * @example Parse a CSV with headers by data
10
- * ```ts
11
- * new ReadableStream({
12
- * start(controller) {
13
- * controller.enqueue("name,age\r\n");
14
- * controller.enqueue("Alice,20\r\n");
15
- * controller.close();
16
- * }
17
- * })
18
- * .pipeThrough(new LexerTransformer())
19
- * .pipeTo(new WritableStream({ write(tokens) {
20
- * for (const token of tokens) {
21
- * console.log(token);
22
- * }
23
- * }}));
24
- * // { type: Field, value: "name", location: {...} }
25
- * // { type: FieldDelimiter, value: ",", location: {...} }
26
- * // { type: Field, value: "age", location: {...} }
27
- * // { type: RecordDelimiter, value: "\r\n", location: {...} }
28
- * // { type: Field, value: "Alice", location: {...} }
29
- * // { type: FieldDelimiter, value: ",", location: {...} }
30
- * // { type: Field, value: "20" }
31
- * // { type: RecordDelimiter, value: "\r\n", location: {...} }
32
- * ```
33
- */
34
- export declare class LexerTransformer extends TransformStream<string, Token[]> {
35
- readonly lexer: Lexer;
36
- constructor(options?: CommonOptions);
37
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { CSVRecord, RecordAssemblerOptions, Token } from './common/types.ts';
2
-
3
- export declare class RecordAssembler<Header extends ReadonlyArray<string>> {
4
- #private;
5
- constructor(options?: RecordAssemblerOptions<Header>);
6
- assemble(tokens: Iterable<Token>, flush?: boolean): IterableIterator<CSVRecord<Header>>;
7
- flush(): Generator<CSVRecord<Header>>;
8
- }
@@ -1,50 +0,0 @@
1
- import { RecordAssembler } from './RecordAssembler.ts';
2
- import { CSVRecord, RecordAssemblerOptions, Token } from './common/types.ts';
3
-
4
- /**
5
- * A transform stream that converts a stream of tokens into a stream of rows.
6
- * @template Header The type of the header row.
7
- * @param options The options for the parser.
8
- *
9
- * @category Low-level API
10
- *
11
- * @example Parse a CSV with headers by data
12
- * ```ts
13
- * new ReadableStream({
14
- * start(controller) {
15
- * controller.enqueue("name,age\r\n");
16
- * controller.enqueue("Alice,20\r\n");
17
- * controller.enqueue("Bob,25\r\n");
18
- * controller.enqueue("Charlie,30\r\n");
19
- * controller.close();
20
- * })
21
- * .pipeThrough(new LexerTransformer())
22
- * .pipeThrough(new RecordAssemblerTransformer())
23
- * .pipeTo(new WritableStream({ write(row) { console.log(row); }}));
24
- * // { name: "Alice", age: "20" }
25
- * // { name: "Bob", age: "25" }
26
- * // { name: "Charlie", age: "30" }
27
- * ```
28
- *
29
- * @example Parse a CSV with headers by options
30
- * ```ts
31
- * new ReadableStream({
32
- * start(controller) {
33
- * controller.enqueue("Alice,20\r\n");
34
- * controller.enqueue("Bob,25\r\n");
35
- * controller.enqueue("Charlie,30\r\n");
36
- * controller.close();
37
- * }
38
- * })
39
- * .pipeThrough(new LexerTransformer())
40
- * .pipeThrough(new RecordAssemblerTransformer({ header: ["name", "age"] }))
41
- * .pipeTo(new WritableStream({ write(row) { console.log(row); }}));
42
- * // { name: "Alice", age: "20" }
43
- * // { name: "Bob", age: "25" }
44
- * // { name: "Charlie", age: "30" }
45
- * ```
46
- */
47
- export declare class RecordAssemblerTransformer<Header extends ReadonlyArray<string>> extends TransformStream<Token[], CSVRecord<Header>> {
48
- readonly assembler: RecordAssembler<Header>;
49
- constructor(options?: RecordAssemblerOptions<Header>);
50
- }
@@ -1,22 +0,0 @@
1
- import { CommonOptions } from './common/types.ts';
2
-
3
- /**
4
- * Asserts that the provided options object contains all the required properties.
5
- * Throws an error if any required property is missing
6
- * or if the delimiter and quotation length is not 1 byte character,
7
- * or if the delimiter is the same as the quotation.
8
- *
9
- * @example
10
- *
11
- * ```ts
12
- * assertCommonOptions({
13
- * quotation: '"',
14
- * delimiter: ',',
15
- * });
16
- * ```
17
- *
18
- * @param options - The options object to be validated.
19
- * @throws {InvalidOptionError} If any required property is missing or if the delimiter is the same as the quotation.
20
- * @throws {TypeError} If any required property is not a string.
21
- */
22
- export declare function assertCommonOptions(options: Required<CommonOptions>): asserts options is Required<CommonOptions>;
@@ -1,15 +0,0 @@
1
- /**
2
- * FiledDelimiter is a symbol for field delimiter of CSV.
3
- * @category Constants
4
- */
5
- export declare const FieldDelimiter: unique symbol;
6
- /**
7
- * RecordDelimiter is a symbol for record delimiter of CSV.
8
- * @category Constants
9
- */
10
- export declare const RecordDelimiter: unique symbol;
11
- /**
12
- * Field is a symbol for field of CSV.
13
- * @category Constants
14
- */
15
- export declare const Field: unique symbol;
@@ -1,34 +0,0 @@
1
- import { Position } from './types.js';
2
-
3
- /**
4
- * Error class for invalid option errors.
5
- */
6
- export declare class InvalidOptionError extends Error {
7
- constructor(message?: string, options?: ErrorOptions);
8
- }
9
- /**
10
- * Options for creating a parse error.
11
- */
12
- export interface ParseErrorOptions extends ErrorOptions {
13
- /**
14
- * The position where the error occurred.
15
- */
16
- position?: Position;
17
- }
18
- /**
19
- * Error class for parse errors.
20
- *
21
- * @remarks
22
- * This error is thrown when a parsing error occurs.
23
- * {@link ParseError} is a subclass of {@link !SyntaxError}.
24
- *
25
- * This is in reference to the specification
26
- * that the error thrown when a parse error occurs in the {@link !JSON.parse} function is {@link !SyntaxError}.
27
- */
28
- export declare class ParseError extends SyntaxError {
29
- /**
30
- * The position where the error occurred.
31
- */
32
- position?: Position;
33
- constructor(message?: string, options?: ParseErrorOptions);
34
- }
@@ -1,228 +0,0 @@
1
- import { Field, FieldDelimiter, RecordDelimiter } from './constants.ts';
2
-
3
- /**
4
- * Position object.
5
- */
6
- export interface Position {
7
- /**
8
- * Line number.
9
- * Starts from 1.
10
- */
11
- line: number;
12
- /**
13
- * Column number.
14
- * Starts from 1.
15
- */
16
- column: number;
17
- /**
18
- * Character offset.
19
- * Starts from 0.
20
- */
21
- offset: number;
22
- }
23
- /**
24
- * Token location object.
25
- */
26
- export interface TokenLocation {
27
- /**
28
- * Start location.
29
- */
30
- start: Position;
31
- /**
32
- * End location.
33
- */
34
- end: Position;
35
- /**
36
- * Row number.
37
- * Starts from 1.
38
- *
39
- * @remarks
40
- * This represents the logical row number in the CSV,
41
- * counting from 1 for the first row, whether it is a header or not.
42
- */
43
- rowNumber: number;
44
- }
45
- /**
46
- * Field token type.
47
- * @category Types
48
- */
49
- export interface FieldToken {
50
- type: typeof Field;
51
- value: string;
52
- location: TokenLocation;
53
- }
54
- /**
55
- * Field delimiter token type.
56
- * @category Types
57
- */
58
- export interface FieldDelimiterToken {
59
- type: typeof FieldDelimiter;
60
- value: string;
61
- location: TokenLocation;
62
- }
63
- /**
64
- * Record delimiter token type.
65
- * @category Types
66
- */
67
- export interface RecordDelimiterToken {
68
- type: typeof RecordDelimiter;
69
- value: string;
70
- location: TokenLocation;
71
- }
72
- /**
73
- * Token is a atomic unit of a CSV file.
74
- * It can be a field, field delimiter, or record delimiter.
75
- * @category Types
76
- */
77
- export type Token = FieldToken | FieldDelimiterToken | RecordDelimiterToken;
78
- /**
79
- * CSV Common Options.
80
- * @category Types
81
- */
82
- export interface CommonOptions {
83
- /**
84
- * CSV field delimiter.
85
- * If you want to parse TSV, specify `'\t'`.
86
- *
87
- * @remarks
88
- * Detail restrictions are as follows:
89
- *
90
- * - Must not be empty
91
- * - Must be a single character
92
- * - Multi-byte characters are not supported
93
- * - Must not include CR or LF
94
- * - Must not be the same as the quotation
95
- *
96
- * @default ','
97
- */
98
- delimiter?: string;
99
- /**
100
- * CSV field quotation.
101
- *
102
- * @default '"'
103
- */
104
- quotation?: string;
105
- }
106
- /**
107
- * CSV Parsing Options for binary.
108
- * @category Types
109
- */
110
- export interface BinaryOptions {
111
- /**
112
- * If the binary is compressed by a compression algorithm,
113
- * the decompressed CSV can be parsed by specifying the algorithm.
114
- *
115
- * @remarks
116
- * Make sure the runtime you are running supports stream decompression.
117
- *
118
- * See {@link https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream#browser_compatibility | DecompressionStream Compatibility}.
119
- */
120
- decomposition?: CompressionFormat;
121
- /**
122
- * You can specify the character encoding of the binary.
123
- *
124
- * @remarks
125
- * {@link !TextDecoderStream} is used internally.
126
- *
127
- * See {@link https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings | Encoding API Compatibility}
128
- * for the encoding formats that can be specified.
129
- *
130
- * @default 'utf-8'
131
- */
132
- charset?: string;
133
- /**
134
- * If the binary has a BOM, you can specify whether to ignore it.
135
- *
136
- * @remarks
137
- * If you specify true, the BOM will be ignored.
138
- * If you specify false or not specify it, the BOM will be treated as a normal character.
139
- * See {@link https://developer.mozilla.org/en-US/docs/Web/API/TextDecoderStream/ignoreBOM | TextDecoderOptions.ignoreBOM} for more information about the BOM.
140
- * @default false
141
- */
142
- ignoreBOM?: boolean;
143
- /**
144
- * If the binary has a invalid character, you can specify whether to throw an error.
145
- *
146
- * @remarks
147
- * If the property is `true` then a decoder will throw a {@link !TypeError}
148
- * if it encounters malformed data while decoding.
149
- *
150
- * If `false` the decoder will substitute the invalid data
151
- * with the replacement character `U+FFFD` (�).
152
- *
153
- * See {@link https://developer.mozilla.org/en-US/docs/Web/API/TextDecoderStream/fatal | TextDecoderOptions.fatal} for more information.
154
- *
155
- * @default false
156
- */
157
- fatal?: boolean;
158
- }
159
- /**
160
- * Record Assembler Options for CSV.
161
- * @category Types
162
- *
163
- * @remarks
164
- * If you specify `header: ['foo', 'bar']`,
165
- * the first record will be treated as a normal record.
166
- *
167
- * If you don't specify `header`,
168
- * the first record will be treated as a header.
169
- */
170
- export interface RecordAssemblerOptions<Header extends ReadonlyArray<string>> {
171
- /**
172
- * CSV header.
173
- *
174
- * @remarks
175
- * If you specify this option,
176
- * the first record will be treated as a normal record.
177
- *
178
- * If you don't specify this option,
179
- * the first record will be treated as a header.
180
- *
181
- * @default undefined
182
- */
183
- header?: Header;
184
- }
185
- /**
186
- * Parse options for CSV string.
187
- * @category Types
188
- */
189
- export interface ParseOptions<Header extends ReadonlyArray<string>> extends CommonOptions, RecordAssemblerOptions<Header> {
190
- }
191
- /**
192
- * Parse options for CSV binary.
193
- * @category Types
194
- */
195
- export interface ParseBinaryOptions<Header extends ReadonlyArray<string>> extends ParseOptions<Header>, BinaryOptions {
196
- }
197
- /**
198
- * CSV Record.
199
- * @category Types
200
- * @template Header Header of the CSV.
201
- *
202
- * @example Header is ["foo", "bar"]
203
- * ```ts
204
- * const record: CSVRecord<["foo", "bar"]> = {
205
- * foo: "1",
206
- * bar: "2",
207
- * };
208
- * ```
209
- */
210
- export type CSVRecord<Header extends ReadonlyArray<string>> = Record<Header[number], string>;
211
- /**
212
- * CSV String.
213
- *
214
- * @category Types
215
- */
216
- export type CSVString = string | ReadableStream<string>;
217
- /**
218
- * CSV Binary.
219
- *
220
- * @category Types
221
- */
222
- export type CSVBinary = ReadableStream<Uint8Array> | Response | ArrayBuffer | Uint8Array;
223
- /**
224
- * CSV.
225
- *
226
- * @category Types
227
- */
228
- export type CSV = CSVString | CSVBinary;
@@ -1,8 +0,0 @@
1
- /**
2
- * Common error handling for parsing CSV data.
3
- *
4
- * @param error - The error to handle.
5
- * @throws {ParseError} When an error occurs while parsing the CSV data.
6
- * @throws {InvalidOptionError} When an invalid option is provided.
7
- */
8
- export declare function commonParseErrorHandling(error: unknown): never;
@@ -1,11 +0,0 @@
1
- export declare const CR = "\r";
2
- export declare const CRLF = "\r\n";
3
- export declare const LF = "\n";
4
- /**
5
- * COMMA is a symbol for comma(,).
6
- */
7
- export declare const COMMA = ",";
8
- /**
9
- * DOUBLE_QUOTE is a symbol for double quote(").
10
- */
11
- export declare const DOUBLE_QUOTE = "\"";
@@ -1,14 +0,0 @@
1
- import { CommonOptions } from './common/types.ts';
2
-
3
- export interface EscapeFieldOptions extends CommonOptions {
4
- quote?: true;
5
- }
6
- /**
7
- * Escape the field.
8
- *
9
- * DO NOT USE THIS FUNCTION BEFORE ASSTPTED BY `{@link assertCommonOptions}`.
10
- * @param value The field value to escape.
11
- * @param options The options.
12
- * @returns The escaped field.
13
- */
14
- export declare function escapeField(value: string, { quotation, delimiter, quote, }?: EscapeFieldOptions): string;
@@ -1,11 +0,0 @@
1
- import { ParseBinaryOptions } from './common/types.ts';
2
-
3
- /**
4
- * Extracts the options from the response object.
5
- *
6
- * @param response - The response object from which to extract the options.
7
- * @param options - The options to merge with the extracted options.
8
- * @returns The options extracted from the response.
9
- * @throws {RangeError} - The content type is not supported.
10
- */
11
- export declare function getOptionsFromResponse<Header extends ReadonlyArray<string>>(response: Response, options?: ParseBinaryOptions<Header>): ParseBinaryOptions<Header>;
@@ -1,19 +0,0 @@
1
- import { InitInput } from 'web-csv-toolbox-wasm';
2
-
3
- /**
4
- * Load WASM module.
5
- *
6
- * This must be called before calling WebAssembly functions.
7
- *
8
- * @example
9
- *
10
- * ```ts
11
- * import { loadWASM, parseStringWASM } from "web-csv-toolbox";
12
- *
13
- * await loadWASM();
14
- *
15
- * const csv = "a,b,c\n1,2,3";
16
- * const parsed = parseStringWASM(csv);
17
- * ```
18
- */
19
- export declare function loadWASM(input?: InitInput | Promise<InitInput>): Promise<void>;
@@ -1,19 +0,0 @@
1
- import { InitInput } from 'web-csv-toolbox-wasm';
2
-
3
- /**
4
- * Load WASM module.
5
- *
6
- * This must be called before calling WebAssembly functions.
7
- *
8
- * @example
9
- *
10
- * ```ts
11
- * import { loadWASM, parseStringWASM } from "web-csv-toolbox";
12
- *
13
- * await loadWASM();
14
- *
15
- * const csv = "a,b,c\n1,2,3";
16
- * const parsed = parseStringWASM(csv);
17
- * ```
18
- */
19
- export declare function loadWASM(input?: InitInput | Promise<InitInput>): Promise<void>;