web-csv-toolbox 0.14.0-next-386eebeaafe5857e28c876345c14c9fe5f1a3774 → 0.14.0-next-978b88933762ecc27270ce746b80a3fa7ed8c4f7
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.
- package/README.md +28 -48
- package/dist/CSVLexer.js +8 -5
- package/dist/CSVLexer.js.map +1 -1
- package/dist/CSVLexerTransformer.d.ts +10 -12
- package/dist/CSVLexerTransformer.js +12 -16
- package/dist/CSVLexerTransformer.js.map +1 -1
- package/dist/CSVRecordAssembler.js +14 -4
- package/dist/CSVRecordAssembler.js.map +1 -1
- package/dist/CSVRecordAssemblerTransformer.d.ts +8 -14
- package/dist/CSVRecordAssemblerTransformer.js +10 -16
- package/dist/CSVRecordAssemblerTransformer.js.map +1 -1
- package/dist/assertCommonOptions.d.ts +1 -1
- package/dist/assertCommonOptions.js.map +1 -1
- package/dist/common/errors.d.ts +32 -0
- package/dist/common/errors.js +18 -0
- package/dist/common/errors.js.map +1 -1
- package/dist/common/types.d.ts +292 -66
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +2 -1
- package/dist/constants.js.map +1 -1
- package/dist/execution/EnginePresets.d.ts +52 -12
- package/dist/execution/EnginePresets.js +1 -1
- package/dist/execution/EnginePresets.js.map +1 -1
- package/dist/execution/InternalEngineConfig.js +40 -18
- package/dist/execution/InternalEngineConfig.js.map +1 -1
- package/dist/execution/worker/parseBinaryInWorker.node.js +3 -4
- package/dist/execution/worker/parseBinaryInWorker.node.js.map +1 -1
- package/dist/execution/worker/parseBinaryInWorker.web.js +3 -4
- package/dist/execution/worker/parseBinaryInWorker.web.js.map +1 -1
- package/dist/execution/worker/parseBinaryInWorkerWASM.node.js +3 -4
- package/dist/execution/worker/parseBinaryInWorkerWASM.node.js.map +1 -1
- package/dist/execution/worker/parseBinaryInWorkerWASM.web.js +3 -4
- package/dist/execution/worker/parseBinaryInWorkerWASM.web.js.map +1 -1
- package/dist/execution/worker/parseStreamInWorker.node.js +3 -4
- package/dist/execution/worker/parseStreamInWorker.node.js.map +1 -1
- package/dist/execution/worker/parseStreamInWorker.web.js +3 -4
- package/dist/execution/worker/parseStreamInWorker.web.js.map +1 -1
- package/dist/execution/worker/parseStringInWorker.node.js +3 -4
- package/dist/execution/worker/parseStringInWorker.node.js.map +1 -1
- package/dist/execution/worker/parseStringInWorker.web.js +3 -4
- package/dist/execution/worker/parseStringInWorker.web.js.map +1 -1
- package/dist/execution/worker/parseStringInWorkerWASM.node.js +3 -4
- package/dist/execution/worker/parseStringInWorkerWASM.node.js.map +1 -1
- package/dist/execution/worker/parseStringInWorkerWASM.web.js +3 -4
- package/dist/execution/worker/parseStringInWorkerWASM.web.js.map +1 -1
- package/dist/execution/worker/parseUint8ArrayStreamInWorker.node.js +3 -4
- package/dist/execution/worker/parseUint8ArrayStreamInWorker.node.js.map +1 -1
- package/dist/execution/worker/parseUint8ArrayStreamInWorker.web.js +3 -4
- package/dist/execution/worker/parseUint8ArrayStreamInWorker.web.js.map +1 -1
- package/dist/getCharsetValidation.constants.node.d.ts +11 -0
- package/dist/getCharsetValidation.constants.node.js +53 -0
- package/dist/getCharsetValidation.constants.node.js.map +1 -0
- package/dist/getCharsetValidation.constants.web.d.ts +36 -0
- package/dist/getCharsetValidation.constants.web.js +53 -0
- package/dist/getCharsetValidation.constants.web.js.map +1 -0
- package/dist/getOptionsFromFile.d.ts +14 -0
- package/dist/getOptionsFromFile.js +12 -0
- package/dist/getOptionsFromFile.js.map +1 -0
- package/dist/getOptionsFromResponse.js +17 -1
- package/dist/getOptionsFromResponse.js.map +1 -1
- package/dist/parseBlob.js +9 -1
- package/dist/parseBlob.js.map +1 -1
- package/dist/parseFile.d.ts +3 -2
- package/dist/parseFile.js +7 -3
- package/dist/parseFile.js.map +1 -1
- package/dist/parseFileToArray.d.ts +27 -0
- package/dist/parseFileToArray.js +12 -0
- package/dist/parseFileToArray.js.map +1 -0
- package/dist/parseFileToStream.d.ts +33 -0
- package/dist/parseFileToStream.js +10 -0
- package/dist/parseFileToStream.js.map +1 -0
- package/dist/utils/convertBinaryToString.js +17 -4
- package/dist/utils/convertBinaryToString.js.map +1 -1
- package/dist/utils/parseMime.js +3 -1
- package/dist/utils/parseMime.js.map +1 -1
- package/dist/utils/types.d.ts +21 -10
- package/dist/web-csv-toolbox.d.ts +3 -0
- package/dist/web-csv-toolbox.js +3 -0
- package/dist/web-csv-toolbox.js.map +1 -1
- package/package.json +7 -1
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
+
import { CSVString } from '../common/types.ts';
|
|
1
2
|
import { DEFAULT_DELIMITER, DEFAULT_QUOTATION, Newline } from '../constants.ts';
|
|
2
|
-
import { CSVString } from '../web-csv-toolbox.ts';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Join CSV field array into a CSV-formatted string with proper escaping.
|
|
5
5
|
*
|
|
6
6
|
* @category Types
|
|
7
7
|
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* This type handles CSV-specific formatting:
|
|
10
|
+
* - Quotes fields containing delimiters, quotations, or newlines
|
|
11
|
+
* - Joins fields with the specified delimiter
|
|
12
|
+
*
|
|
8
13
|
* @example Default
|
|
9
14
|
*
|
|
10
15
|
* ```ts
|
|
11
16
|
* const header = ["name", "age", "city", "zip"];
|
|
12
17
|
*
|
|
13
|
-
* type _ =
|
|
18
|
+
* type _ = JoinCSVFields<typeof header>
|
|
14
19
|
* // `name,age,city,zip`
|
|
15
20
|
* ```
|
|
16
21
|
*
|
|
@@ -19,22 +24,28 @@ import { CSVString } from '../web-csv-toolbox.ts';
|
|
|
19
24
|
* ```ts
|
|
20
25
|
* const header = ["name", "a\nge", "city", "zip"];
|
|
21
26
|
*
|
|
22
|
-
* type _ =
|
|
27
|
+
* type _ = JoinCSVFields<typeof header, "@", "$">
|
|
23
28
|
* // `name@$a\nge$@city@zip`
|
|
24
29
|
* ```
|
|
25
30
|
*/
|
|
26
|
-
export type
|
|
31
|
+
export type JoinCSVFields<Chars extends ReadonlyArray<string | number | boolean | bigint>, Delimiter extends string = DEFAULT_DELIMITER, Quotation extends string = DEFAULT_QUOTATION, Nl extends string = Exclude<Newline, Delimiter | Quotation>> = Chars extends readonly [infer F, ...infer R] ? F extends string ? R extends string[] ? `${F extends `${string}${Nl | Delimiter | Quotation}${string}` ? `${Quotation}${F}${Quotation}` : F}${R extends [] ? "" : Delimiter}${JoinCSVFields<R, Delimiter, Quotation>}` : string : string : "";
|
|
27
32
|
/**
|
|
28
|
-
*
|
|
33
|
+
* Split CSV-formatted string into field array with proper unescaping.
|
|
29
34
|
*
|
|
30
35
|
* @category Types
|
|
31
36
|
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* This type handles CSV-specific parsing:
|
|
39
|
+
* - Unquotes quoted fields
|
|
40
|
+
* - Handles escaped quotation marks
|
|
41
|
+
* - Splits by the specified delimiter
|
|
42
|
+
*
|
|
32
43
|
* @example Default
|
|
33
44
|
*
|
|
34
45
|
* ```ts
|
|
35
46
|
* const header = `name,age,city,zip`;
|
|
36
47
|
*
|
|
37
|
-
* type _ =
|
|
48
|
+
* type _ = SplitCSVFields<typeof header>
|
|
38
49
|
* // ["name", "age", "city", "zip"]
|
|
39
50
|
* ```
|
|
40
51
|
*
|
|
@@ -44,11 +55,11 @@ export type Join<Chars extends ReadonlyArray<string | number | boolean | bigint>
|
|
|
44
55
|
* const header = `name@$a
|
|
45
56
|
* ge$@city@zip`;
|
|
46
57
|
*
|
|
47
|
-
* type _ =
|
|
58
|
+
* type _ = SplitCSVFields<typeof header, "@", "$">
|
|
48
59
|
* // ["name", "a\nge", "city", "zip"]
|
|
49
60
|
* ```
|
|
50
61
|
*/
|
|
51
|
-
export type
|
|
62
|
+
export type SplitCSVFields<Char extends string, Delimiter extends string = DEFAULT_DELIMITER, Quotation extends string = DEFAULT_QUOTATION, Escaping extends boolean = false, Col extends string = "", Result extends string[] = []> = Char extends `${Delimiter}${infer R}` ? Escaping extends true ? SplitCSVFields<R, Delimiter, Quotation, true, `${Col}${Delimiter}`, Result> : SplitCSVFields<R, Delimiter, Quotation, false, "", [...Result, Col]> : Char extends `${Quotation}${infer R}` ? Escaping extends true ? R extends "" | Delimiter | `${Delimiter}${string}` ? SplitCSVFields<R, Delimiter, Quotation, false, Col, Result> : SplitCSVFields<R, Delimiter, Quotation, true, `${Col}${Quotation}`, Result> : SplitCSVFields<R, Delimiter, Quotation, true, Col, Result> : Char extends `${infer F}${infer R}` ? SplitCSVFields<R, Delimiter, Quotation, Escaping, `${Col}${F}`, Result> : [...Result, Col] extends [""] ? readonly string[] : readonly [...Result, Col];
|
|
52
63
|
type ExtractString<Source extends CSVString> = Source extends `${infer S}` | ReadableStream<infer S> ? S : string;
|
|
53
64
|
type ExtractCSVBody<CSVSource extends CSVString, Delimiter extends string = DEFAULT_DELIMITER, Quotation extends string = DEFAULT_QUOTATION, Nl extends string = Exclude<Newline, Delimiter | Quotation>, Escaping extends boolean = false> = ExtractString<CSVSource> extends `${Quotation}${infer R}` ? Escaping extends true ? R extends Delimiter | Nl | `${Delimiter | Nl}${string}` ? ExtractCSVBody<R, Delimiter, Quotation, Nl, false> : ExtractCSVBody<R, Delimiter, Quotation, Nl, true> : ExtractCSVBody<R, Delimiter, Quotation, Nl, true> : ExtractString<CSVSource> extends `${infer _ extends Nl}${infer R}` ? Escaping extends true ? ExtractCSVBody<R, Delimiter, Quotation, Nl, true> : R : ExtractString<CSVSource> extends `${infer _}${infer R}` ? ExtractCSVBody<R, Delimiter, Quotation, Nl, Escaping> : "";
|
|
54
65
|
/**
|
|
@@ -110,5 +121,5 @@ export type ExtractCSVHeader<CSVSource extends CSVString, Delimiter extends stri
|
|
|
110
121
|
* // ["name", "a\nge"]
|
|
111
122
|
* ```
|
|
112
123
|
*/
|
|
113
|
-
export type PickCSVHeader<CSVSource extends CSVString, Delimiter extends string = DEFAULT_DELIMITER, Quotation extends string = DEFAULT_QUOTATION> = ExtractString<CSVSource> extends `${infer S}` ?
|
|
124
|
+
export type PickCSVHeader<CSVSource extends CSVString, Delimiter extends string = DEFAULT_DELIMITER, Quotation extends string = DEFAULT_QUOTATION> = ExtractString<CSVSource> extends `${infer S}` ? SplitCSVFields<ExtractCSVHeader<S, Delimiter, Quotation>, Delimiter, Quotation> : ReadonlyArray<string>;
|
|
114
125
|
export {};
|
|
@@ -8,6 +8,9 @@ export * from './parse.ts';
|
|
|
8
8
|
export * from './parseBinary.ts';
|
|
9
9
|
export * from './parseBlob.ts';
|
|
10
10
|
export * from './parseFile.ts';
|
|
11
|
+
export * from './parseFileToArray.ts';
|
|
12
|
+
export * from './parseFileToStream.ts';
|
|
13
|
+
export * from './getOptionsFromFile.ts';
|
|
11
14
|
export * from './parseRequest.ts';
|
|
12
15
|
export * from './parseResponse.ts';
|
|
13
16
|
export * from './parseString.ts';
|
package/dist/web-csv-toolbox.js
CHANGED
|
@@ -7,6 +7,9 @@ export { parse } from './parse.js';
|
|
|
7
7
|
export { parseBinary } from './parseBinary.js';
|
|
8
8
|
export { parseBlob } from './parseBlob.js';
|
|
9
9
|
export { parseFile } from './parseFile.js';
|
|
10
|
+
export { parseFileToArray } from './parseFileToArray.js';
|
|
11
|
+
export { parseFileToStream } from './parseFileToStream.js';
|
|
12
|
+
export { getOptionsFromFile } from './getOptionsFromFile.js';
|
|
10
13
|
export { parseRequest } from './parseRequest.js';
|
|
11
14
|
export { parseResponse } from './parseResponse.js';
|
|
12
15
|
export { parseString } from './parseString.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-csv-toolbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-csv-toolbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-csv-toolbox",
|
|
3
|
-
"version": "0.14.0-next-
|
|
3
|
+
"version": "0.14.0-next-978b88933762ecc27270ce746b80a3fa7ed8c4f7",
|
|
4
4
|
"description": "A CSV Toolbox utilizing Web Standard APIs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/web-csv-toolbox.js",
|
|
@@ -56,6 +56,12 @@
|
|
|
56
56
|
"browser": "./dist/getOptionsFromResponse.constants.web.js",
|
|
57
57
|
"default": "./dist/getOptionsFromResponse.constants.web.js"
|
|
58
58
|
},
|
|
59
|
+
"#getCharsetValidation.constants.js": {
|
|
60
|
+
"types": "./dist/getCharsetValidation.constants.d.ts",
|
|
61
|
+
"node": "./dist/getCharsetValidation.constants.node.js",
|
|
62
|
+
"browser": "./dist/getCharsetValidation.constants.web.js",
|
|
63
|
+
"default": "./dist/getCharsetValidation.constants.web.js"
|
|
64
|
+
},
|
|
59
65
|
"#execution/worker/parseStringInWorker.js": {
|
|
60
66
|
"types": "./dist/execution/worker/parseStringInWorker.d.ts",
|
|
61
67
|
"node": "./dist/execution/worker/parseStringInWorker.node.js",
|