@konstit/csv 0.4.1 → 0.5.0
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 +152 -463
- package/THIRD_PARTY_NOTICES.md +7 -1
- package/dist/api.d.ts +169 -44
- package/dist/api.js +75 -368
- package/dist/batches.d.ts +250 -7
- package/dist/batches.js +135 -83
- package/dist/cli-command.d.ts +7 -0
- package/dist/cli-command.js +350 -0
- package/dist/cli-schema.d.ts +111 -0
- package/dist/cli-schema.js +219 -0
- package/dist/cli.js +2 -604
- package/dist/file-stream.d.ts +57 -2
- package/dist/file-stream.js +244 -36
- package/dist/files.d.ts +149 -3
- package/dist/files.js +37 -29
- package/dist/filter.d.ts +80 -0
- package/dist/format-bytes.d.ts +1 -0
- package/dist/format-bytes.js +11 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -14
- package/dist/inspect-file.d.ts +12 -0
- package/dist/inspect-file.js +88 -0
- package/dist/latin1-rows.d.ts +5 -0
- package/dist/latin1-rows.js +122 -0
- package/dist/materialize-field.d.ts +3 -0
- package/dist/materialize-field.js +31 -0
- package/dist/native.d.ts +51 -2
- package/dist/native.js +43 -4
- package/dist/normalize.d.ts +32 -2
- package/dist/normalize.js +51 -2
- package/dist/options-snapshot.d.ts +3 -0
- package/dist/options-snapshot.js +51 -0
- package/dist/options.d.ts +25 -10
- package/dist/options.js +0 -6
- package/dist/parser.d.ts +309 -4
- package/dist/parser.js +128 -31
- package/dist/strict-schema.d.ts +5 -3
- package/dist/strict-schema.js +4 -1
- package/dist/types.d.ts +355 -121
- package/dist/zip-reader.d.ts +11 -1
- package/dist/zip-reader.js +12 -3
- package/package.json +44 -29
- package/prebuilds/darwin-arm64/libcsv_native.dylib +0 -0
- package/prebuilds/darwin-x64/libcsv_native.dylib +0 -0
- package/prebuilds/linux-x64/libcsv_native.so +0 -0
- package/prebuilds/manifest.json +9 -8
- package/prebuilds/provenance/darwin-arm64.json +1 -1
- package/prebuilds/provenance/darwin-x64.json +1 -1
- package/prebuilds/provenance/linux-x64.json +1 -1
- package/dist/worker-count.d.ts +0 -2
- package/dist/worker-count.js +0 -96
- package/dist/worker-factory.d.ts +0 -3
- package/dist/worker-factory.js +0 -9
- package/dist/worker-filter.d.ts +0 -29
- package/dist/worker-filter.js +0 -46
- package/dist/worker-module.d.ts +0 -1
- package/dist/worker-module.js +0 -4
- package/dist/worker-pool.d.ts +0 -17
- package/dist/worker-pool.js +0 -290
- package/dist/worker-rows.d.ts +0 -8
- package/dist/worker-rows.js +0 -118
- package/dist/workers/count.worker.d.ts +0 -1
- package/dist/workers/count.worker.js +0 -49
- package/dist/workers/rows.worker.d.ts +0 -1
- package/dist/workers/rows.worker.js +0 -85
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { csv } from "./api.js";
|
|
2
|
+
import {
|
|
3
|
+
csvCommand
|
|
4
|
+
} from "./cli-schema.js";
|
|
5
|
+
import { formatBytes } from "./format-bytes.js";
|
|
6
|
+
import { inspectCsvFile } from "./inspect-file.js";
|
|
7
|
+
import {
|
|
8
|
+
normalizeColumns,
|
|
9
|
+
normalizeFilterColumn
|
|
10
|
+
} from "./normalize.js";
|
|
11
|
+
const MAX_FILTER_NESTING = 128;
|
|
12
|
+
const OUTPUT_BUFFER_SIZE = 65536;
|
|
13
|
+
export async function runCli(arguments_, customOutput) {
|
|
14
|
+
const result = csvCommand.tryParse(arguments_);
|
|
15
|
+
if (result.type === "display")
|
|
16
|
+
return csvCommand.runParsed(result, customOutput && { stdout: (text) => customOutput.log(text.trimEnd()) });
|
|
17
|
+
const output = customOutput ?? {
|
|
18
|
+
log: console.log,
|
|
19
|
+
error: console.error,
|
|
20
|
+
write: (chunk) => Bun.write(Bun.stdout, chunk)
|
|
21
|
+
};
|
|
22
|
+
if (result.type === "error")
|
|
23
|
+
return usageError(output, result.error.message, `${result.error.commandPath.join(" ")} --help`);
|
|
24
|
+
const { subcommand } = result.value;
|
|
25
|
+
switch (subcommand.name) {
|
|
26
|
+
case "count":
|
|
27
|
+
return runCount(subcommand.args, output);
|
|
28
|
+
case "lines":
|
|
29
|
+
return runLines(subcommand.args, output);
|
|
30
|
+
case "probe":
|
|
31
|
+
return runProbe(subcommand.args.path, subcommand.args["zip-entry"], output);
|
|
32
|
+
case "completion":
|
|
33
|
+
return runCompletion(subcommand.args.shell, output);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function runCompletion(shell, output) {
|
|
37
|
+
const { generateCompletion } = await import("@konstit/cli/completion");
|
|
38
|
+
output.log(generateCompletion(csvCommand, shell).trimEnd());
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
async function runProbe(path, entry, output) {
|
|
42
|
+
try {
|
|
43
|
+
const result = await inspectCsvFile(path, entry);
|
|
44
|
+
output.log([
|
|
45
|
+
`File size: ${formatBytes(result.size)}`,
|
|
46
|
+
`Encoding: ${result.encoding}`,
|
|
47
|
+
`Delimiter: ${result.delimiter === void 0 ? "undetermined" : JSON.stringify(result.delimiter)}`,
|
|
48
|
+
`Line endings: ${result.lineEnding}`,
|
|
49
|
+
`Compression: ${result.compression}`,
|
|
50
|
+
`First record columns: ${String(result.firstRecordColumns ?? "unknown")}`
|
|
51
|
+
].join(`
|
|
52
|
+
`));
|
|
53
|
+
return 0;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
output.error(`csv: ${error instanceof Error ? error.message : String(error)}`);
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function runCount(args, output) {
|
|
60
|
+
let options;
|
|
61
|
+
try {
|
|
62
|
+
options = parseCommonOptions(args);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return usageError(output, error instanceof Error ? error.message : String(error), "csv count --help");
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
output.log(await csv.count(args.path, options));
|
|
68
|
+
return 0;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
71
|
+
output.error(`csv: ${message}`);
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function runLines(args, output) {
|
|
76
|
+
let input;
|
|
77
|
+
try {
|
|
78
|
+
input = parseLinesInput(args);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
return usageError(output, error instanceof Error ? error.message : String(error), "csv lines --help");
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
await streamLines(input, output);
|
|
84
|
+
return 0;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (isBrokenPipe(error))
|
|
87
|
+
return 0;
|
|
88
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
89
|
+
output.error(`csv: ${message}`);
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function parseLinesInput(values) {
|
|
94
|
+
const { limit } = values;
|
|
95
|
+
const options = parseCommonOptions(values, values.strict === !0 && limit !== void 0);
|
|
96
|
+
if (limit !== void 0 && options.strict === !0) {
|
|
97
|
+
if (options.compression !== "none")
|
|
98
|
+
throw Error("--strict with --limit does not support compressed input");
|
|
99
|
+
if (options.delimiter === "auto")
|
|
100
|
+
throw Error("--strict with --limit requires a fixed input delimiter");
|
|
101
|
+
if (options.encoding === "auto")
|
|
102
|
+
throw Error("--strict with --limit requires a fixed input encoding");
|
|
103
|
+
if (options.chunkSize !== void 0 && options.chunkSize !== 1)
|
|
104
|
+
throw Error("--strict with --limit requires --chunk-size 1");
|
|
105
|
+
options.chunkSize = 1;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
json: values.json,
|
|
109
|
+
...limit === void 0 ? {} : { limit },
|
|
110
|
+
options,
|
|
111
|
+
outputDelimiter: values["output-delimiter"],
|
|
112
|
+
path: values.path
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function parseCommonOptions(values, fixedFormat = !1) {
|
|
116
|
+
const options = values.strict ? { strict: !0 } : { where: parseWhereOptions(values) };
|
|
117
|
+
options.delimiter = values.delimiter ?? (fixedFormat ? "," : "auto");
|
|
118
|
+
options.encoding = values.encoding ?? (fixedFormat ? "utf8" : "auto");
|
|
119
|
+
if (values["chunk-size"] !== void 0)
|
|
120
|
+
options.chunkSize = values["chunk-size"];
|
|
121
|
+
if (values["fixed-columns"] !== void 0)
|
|
122
|
+
options.fixedColumns = values["fixed-columns"];
|
|
123
|
+
if (values.columns !== void 0)
|
|
124
|
+
options.columns = parseColumns(values.columns, "columns");
|
|
125
|
+
if (values["expected-header"].length > 0)
|
|
126
|
+
options.expectedHeaders = values["expected-header"];
|
|
127
|
+
if (values["require-header"] === !0)
|
|
128
|
+
options.requireHeader = !0;
|
|
129
|
+
if (values["min-data-rows"] !== void 0)
|
|
130
|
+
options.minDataRows = values["min-data-rows"];
|
|
131
|
+
options.compression = parseCompression(values) ?? (fixedFormat ? "none" : "auto");
|
|
132
|
+
return options;
|
|
133
|
+
}
|
|
134
|
+
function parseColumnIndex(value, label) {
|
|
135
|
+
const number = Number(value);
|
|
136
|
+
if (!Number.isSafeInteger(number) || number < 0)
|
|
137
|
+
throw Error(`${label} must be an integer greater than or equal to 0: ${value}`);
|
|
138
|
+
return number;
|
|
139
|
+
}
|
|
140
|
+
function parseColumns(value, label) {
|
|
141
|
+
const columns = value.length === 0 ? [] : value.split(",").map((column) => parseColumnIndex(column, label));
|
|
142
|
+
normalizeColumns(columns);
|
|
143
|
+
return columns;
|
|
144
|
+
}
|
|
145
|
+
function parseCompression(values) {
|
|
146
|
+
const compression = values.compression;
|
|
147
|
+
const zipEntry = values["zip-entry"];
|
|
148
|
+
const maxCompressionRatio = values["max-compression-ratio"];
|
|
149
|
+
const maxDecompressedBytes = values["max-decompressed-bytes"];
|
|
150
|
+
if (compression !== "zip") {
|
|
151
|
+
if (zipEntry !== void 0)
|
|
152
|
+
throw Error("--zip-entry requires --compression zip");
|
|
153
|
+
return compression;
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
entry: zipEntry,
|
|
157
|
+
format: "zip",
|
|
158
|
+
...maxCompressionRatio === void 0 ? {} : { maxCompressionRatio },
|
|
159
|
+
...maxDecompressedBytes === void 0 ? {} : { maxDecompressedBytes }
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
async function streamLines(input, output) {
|
|
163
|
+
let chunks = [];
|
|
164
|
+
let chunksLength = 0;
|
|
165
|
+
let emitted = 0;
|
|
166
|
+
batches:
|
|
167
|
+
for await (const rows of csv.rows(input.path, input.options)) {
|
|
168
|
+
for (const row of rows) {
|
|
169
|
+
const record = input.json ? `${JSON.stringify(row)}
|
|
170
|
+
` : serializeCsvRecord(row, input.outputDelimiter);
|
|
171
|
+
chunks.push(record);
|
|
172
|
+
chunksLength += record.length;
|
|
173
|
+
++emitted;
|
|
174
|
+
if (chunksLength >= OUTPUT_BUFFER_SIZE) {
|
|
175
|
+
await output.write(chunks.join(""));
|
|
176
|
+
chunks = [];
|
|
177
|
+
chunksLength = 0;
|
|
178
|
+
}
|
|
179
|
+
if (emitted === input.limit)
|
|
180
|
+
break batches;
|
|
181
|
+
}
|
|
182
|
+
if (chunksLength > 0) {
|
|
183
|
+
await output.write(chunks.join(""));
|
|
184
|
+
chunks = [];
|
|
185
|
+
chunksLength = 0;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (chunksLength > 0)
|
|
189
|
+
await output.write(chunks.join(""));
|
|
190
|
+
}
|
|
191
|
+
function serializeCsvRecord(row, delimiter) {
|
|
192
|
+
return `${row.map((field) => serializeCsvField(field, delimiter)).join(delimiter)}
|
|
193
|
+
`;
|
|
194
|
+
}
|
|
195
|
+
function serializeCsvField(field, delimiter) {
|
|
196
|
+
if (!field.includes(delimiter) && !field.includes('"') && !field.includes("\r") && !field.includes(`
|
|
197
|
+
`))
|
|
198
|
+
return field;
|
|
199
|
+
return `"${field.replaceAll('"', '""')}"`;
|
|
200
|
+
}
|
|
201
|
+
function isBrokenPipe(error) {
|
|
202
|
+
return isObject(error) && error.code === "EPIPE";
|
|
203
|
+
}
|
|
204
|
+
function parseWhereOptions(values) {
|
|
205
|
+
const filters = [];
|
|
206
|
+
if (values.where !== void 0)
|
|
207
|
+
filters.push(parseWhereFilter(values.where, "--where"));
|
|
208
|
+
for (const { key, value } of values["where-eq"]) {
|
|
209
|
+
const column = parseFilterColumn(key, "--where-eq");
|
|
210
|
+
filters.push(csv.column(column).equals(value));
|
|
211
|
+
}
|
|
212
|
+
for (const { key, value } of values["where-neq"]) {
|
|
213
|
+
const column = parseFilterColumn(key, "--where-neq");
|
|
214
|
+
filters.push(csv.column(column).doesNotEqual(value));
|
|
215
|
+
}
|
|
216
|
+
const inValuesByColumn = new Map;
|
|
217
|
+
for (const { key, value } of values["where-in"]) {
|
|
218
|
+
const column = parseFilterColumn(key, "--where-in");
|
|
219
|
+
const columnValues = inValuesByColumn.get(column);
|
|
220
|
+
if (columnValues === void 0)
|
|
221
|
+
inValuesByColumn.set(column, [value]);
|
|
222
|
+
else
|
|
223
|
+
columnValues.push(value);
|
|
224
|
+
}
|
|
225
|
+
for (const [column, inValues] of inValuesByColumn)
|
|
226
|
+
filters.push(csv.column(column).isOneOf(inValues));
|
|
227
|
+
const notInValuesByColumn = new Map;
|
|
228
|
+
for (const { key, value } of values["where-noin"]) {
|
|
229
|
+
const column = parseFilterColumn(key, "--where-noin");
|
|
230
|
+
const columnValues = notInValuesByColumn.get(column);
|
|
231
|
+
if (columnValues === void 0)
|
|
232
|
+
notInValuesByColumn.set(column, [value]);
|
|
233
|
+
else
|
|
234
|
+
columnValues.push(value);
|
|
235
|
+
}
|
|
236
|
+
for (const [column, notInValues] of notInValuesByColumn)
|
|
237
|
+
filters.push(csv.column(column).isNoneOf(notInValues));
|
|
238
|
+
for (const { key, value } of values["where-prefix"]) {
|
|
239
|
+
const column = parseFilterColumn(key, "--where-prefix");
|
|
240
|
+
filters.push(csv.column(column).startsWith(value));
|
|
241
|
+
}
|
|
242
|
+
for (const expression of values["where-regex"])
|
|
243
|
+
filters.push(parseRegexExpression(expression));
|
|
244
|
+
const first = filters[0];
|
|
245
|
+
if (first === void 0)
|
|
246
|
+
return;
|
|
247
|
+
return filters.length === 1 ? first : csv.all(first, ...filters.slice(1));
|
|
248
|
+
}
|
|
249
|
+
function parseFilterColumn(key, option) {
|
|
250
|
+
return normalizeFilterColumn(parseColumnIndex(key, `${option} column`));
|
|
251
|
+
}
|
|
252
|
+
function parseRegexExpression({ key, value }) {
|
|
253
|
+
const column = parseFilterColumn(key, "--where-regex");
|
|
254
|
+
const closingSlash = value.lastIndexOf("/");
|
|
255
|
+
if (!value.startsWith("/") || closingSlash === 0)
|
|
256
|
+
throw Error(`--where-regex must use <column>=/<pattern>/<flags>: ${JSON.stringify(`${key}=${value}`)}`);
|
|
257
|
+
const source = value.slice(1, closingSlash);
|
|
258
|
+
const flags = value.slice(closingSlash + 1);
|
|
259
|
+
return csv.column(column).hasMatch(new RegExp(source, flags));
|
|
260
|
+
}
|
|
261
|
+
function parseWhereFilter(value, label, depth = 0) {
|
|
262
|
+
if (depth > MAX_FILTER_NESTING)
|
|
263
|
+
throw Error(`--where nesting exceeds ${MAX_FILTER_NESTING}`);
|
|
264
|
+
if (!isObject(value))
|
|
265
|
+
throw Error(`${label} must be a JSON object`);
|
|
266
|
+
if ("all" in value) {
|
|
267
|
+
requireExactKeys(value, ["all"], label);
|
|
268
|
+
return parseWhereGroup(value.all, `${label}.all`, csv.all, depth);
|
|
269
|
+
}
|
|
270
|
+
if ("any" in value) {
|
|
271
|
+
requireExactKeys(value, ["any"], label);
|
|
272
|
+
return parseWhereGroup(value.any, `${label}.any`, csv.any, depth);
|
|
273
|
+
}
|
|
274
|
+
if ("not" in value) {
|
|
275
|
+
requireExactKeys(value, ["not"], label);
|
|
276
|
+
return csv.not(parseWhereFilter(value.not, `${label}.not`, depth + 1));
|
|
277
|
+
}
|
|
278
|
+
return parseWherePredicate(value, label);
|
|
279
|
+
}
|
|
280
|
+
function parseWhereGroup(value, label, combine, depth) {
|
|
281
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
282
|
+
throw Error(`${label} must be a non-empty array`);
|
|
283
|
+
const first = parseWhereFilter(value[0], `${label}[0]`, depth + 1);
|
|
284
|
+
const rest = value.slice(1).map((filter, index) => parseWhereFilter(filter, `${label}[${String(index + 1)}]`, depth + 1));
|
|
285
|
+
return combine(first, ...rest);
|
|
286
|
+
}
|
|
287
|
+
function parseWherePredicate(value, label) {
|
|
288
|
+
const column = value.column;
|
|
289
|
+
if (typeof column !== "number")
|
|
290
|
+
throw Error(`${label}.column must be a number`);
|
|
291
|
+
normalizeFilterColumn(column);
|
|
292
|
+
if ("equals" in value) {
|
|
293
|
+
requireExactKeys(value, ["column", "equals"], label);
|
|
294
|
+
return csv.column(column).equals(requireString(value.equals, `${label}.equals`));
|
|
295
|
+
}
|
|
296
|
+
if ("in" in value) {
|
|
297
|
+
requireExactKeys(value, ["column", "in"], label);
|
|
298
|
+
if (!Array.isArray(value.in) || value.in.length === 0)
|
|
299
|
+
throw Error(`${label}.in must be a non-empty string array`);
|
|
300
|
+
return csv.column(column).isOneOf(value.in.map((item, index) => requireString(item, `${label}.in[${String(index)}]`)));
|
|
301
|
+
}
|
|
302
|
+
if ("notEquals" in value) {
|
|
303
|
+
requireExactKeys(value, ["column", "notEquals"], label);
|
|
304
|
+
return csv.column(column).doesNotEqual(requireString(value.notEquals, `${label}.notEquals`));
|
|
305
|
+
}
|
|
306
|
+
if ("notIn" in value) {
|
|
307
|
+
requireExactKeys(value, ["column", "notIn"], label);
|
|
308
|
+
if (!Array.isArray(value.notIn) || value.notIn.length === 0)
|
|
309
|
+
throw Error(`${label}.notIn must be a non-empty string array`);
|
|
310
|
+
return csv.column(column).isNoneOf(value.notIn.map((item, index) => requireString(item, `${label}.notIn[${String(index)}]`)));
|
|
311
|
+
}
|
|
312
|
+
if ("startsWith" in value) {
|
|
313
|
+
requireExactKeys(value, ["column", "startsWith"], label);
|
|
314
|
+
return csv.column(column).startsWith(requireString(value.startsWith, `${label}.startsWith`));
|
|
315
|
+
}
|
|
316
|
+
if ("regex" in value) {
|
|
317
|
+
requireExactKeys(value, ["column", "regex"], label);
|
|
318
|
+
if (!isObject(value.regex))
|
|
319
|
+
throw Error(`${label}.regex must contain source and optional flags strings`);
|
|
320
|
+
requireExactKeys(value.regex, ["source", "flags"], `${label}.regex`, !0);
|
|
321
|
+
const source = requireString(value.regex.source, `${label}.regex.source`);
|
|
322
|
+
const flags = value.regex.flags === void 0 ? "" : requireString(value.regex.flags, `${label}.regex.flags`);
|
|
323
|
+
return csv.column(column).hasMatch(new RegExp(source, flags));
|
|
324
|
+
}
|
|
325
|
+
throw Error(`${label} must contain equals, in, notEquals, notIn, startsWith, or regex`);
|
|
326
|
+
}
|
|
327
|
+
function isObject(value) {
|
|
328
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
329
|
+
}
|
|
330
|
+
function requireString(value, label) {
|
|
331
|
+
if (typeof value !== "string")
|
|
332
|
+
throw Error(`${label} must be a string`);
|
|
333
|
+
return value;
|
|
334
|
+
}
|
|
335
|
+
function requireExactKeys(value, allowedKeys, label, allowMissing = !1) {
|
|
336
|
+
const keys = Object.keys(value);
|
|
337
|
+
const unknownKey = keys.find((key) => !allowedKeys.includes(key));
|
|
338
|
+
if (unknownKey !== void 0)
|
|
339
|
+
throw Error(`${label} contains unknown property: ${unknownKey}`);
|
|
340
|
+
if (!allowMissing) {
|
|
341
|
+
const missingKey = allowedKeys.find((key) => !Object.hasOwn(value, key));
|
|
342
|
+
if (missingKey !== void 0)
|
|
343
|
+
throw Error(`${label} is missing property: ${missingKey}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function usageError(output, message, helpCommand) {
|
|
347
|
+
output.error(`csv: ${message}
|
|
348
|
+
Run '${helpCommand}' for usage.`);
|
|
349
|
+
return 2;
|
|
350
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type Infer } from '@konstit/cli';
|
|
2
|
+
declare const count: import("@konstit/cli").HandledCommand<"count", {
|
|
3
|
+
path: string;
|
|
4
|
+
"zip-entry": string | undefined;
|
|
5
|
+
delimiter: string | undefined;
|
|
6
|
+
encoding: "utf8" | "utf-16le" | "latin1" | "ibm866" | "iso-8859-2" | "iso-8859-3" | "iso-8859-4" | "iso-8859-5" | "iso-8859-6" | "iso-8859-7" | "iso-8859-8" | "iso-8859-8-i" | "iso-8859-10" | "iso-8859-13" | "iso-8859-14" | "iso-8859-15" | "iso-8859-16" | "koi8-r" | "koi8-u" | "macintosh" | "windows-874" | "windows-1250" | "windows-1251" | "windows-1252" | "windows-1253" | "windows-1254" | "windows-1255" | "windows-1256" | "windows-1257" | "windows-1258" | "x-mac-cyrillic" | "gbk" | "gb18030" | "big5" | "euc-jp" | "iso-2022-jp" | "shift_jis" | "euc-kr" | "utf-16be" | "x-user-defined" | "auto" | undefined;
|
|
7
|
+
compression: "auto" | "zip" | "gzip" | "deflate" | "deflate-raw" | "brotli" | "zstd" | "none" | undefined;
|
|
8
|
+
"chunk-size": number | undefined;
|
|
9
|
+
"max-compression-ratio": number | undefined;
|
|
10
|
+
"max-decompressed-bytes": number | undefined;
|
|
11
|
+
strict: boolean;
|
|
12
|
+
"fixed-columns": number | undefined;
|
|
13
|
+
columns: string | undefined;
|
|
14
|
+
"expected-header": readonly string[];
|
|
15
|
+
"require-header": boolean;
|
|
16
|
+
"min-data-rows": number | undefined;
|
|
17
|
+
where: unknown;
|
|
18
|
+
"where-eq": readonly import("@konstit/cli").KeyValuePair[];
|
|
19
|
+
"where-neq": readonly import("@konstit/cli").KeyValuePair[];
|
|
20
|
+
"where-in": readonly import("@konstit/cli").KeyValuePair[];
|
|
21
|
+
"where-noin": readonly import("@konstit/cli").KeyValuePair[];
|
|
22
|
+
"where-prefix": readonly import("@konstit/cli").KeyValuePair[];
|
|
23
|
+
"where-regex": readonly import("@konstit/cli").KeyValuePair[];
|
|
24
|
+
}, {}, false, "filters" | "zip-limits" | "schema">;
|
|
25
|
+
declare const lines: import("@konstit/cli").HandledCommand<"lines", {
|
|
26
|
+
path: string;
|
|
27
|
+
"zip-entry": string | undefined;
|
|
28
|
+
delimiter: string | undefined;
|
|
29
|
+
encoding: "utf8" | "utf-16le" | "latin1" | "ibm866" | "iso-8859-2" | "iso-8859-3" | "iso-8859-4" | "iso-8859-5" | "iso-8859-6" | "iso-8859-7" | "iso-8859-8" | "iso-8859-8-i" | "iso-8859-10" | "iso-8859-13" | "iso-8859-14" | "iso-8859-15" | "iso-8859-16" | "koi8-r" | "koi8-u" | "macintosh" | "windows-874" | "windows-1250" | "windows-1251" | "windows-1252" | "windows-1253" | "windows-1254" | "windows-1255" | "windows-1256" | "windows-1257" | "windows-1258" | "x-mac-cyrillic" | "gbk" | "gb18030" | "big5" | "euc-jp" | "iso-2022-jp" | "shift_jis" | "euc-kr" | "utf-16be" | "x-user-defined" | "auto" | undefined;
|
|
30
|
+
compression: "auto" | "zip" | "gzip" | "deflate" | "deflate-raw" | "brotli" | "zstd" | "none" | undefined;
|
|
31
|
+
"chunk-size": number | undefined;
|
|
32
|
+
"max-compression-ratio": number | undefined;
|
|
33
|
+
"max-decompressed-bytes": number | undefined;
|
|
34
|
+
strict: boolean;
|
|
35
|
+
"fixed-columns": number | undefined;
|
|
36
|
+
columns: string | undefined;
|
|
37
|
+
"expected-header": readonly string[];
|
|
38
|
+
"require-header": boolean;
|
|
39
|
+
"min-data-rows": number | undefined;
|
|
40
|
+
where: unknown;
|
|
41
|
+
"where-eq": readonly import("@konstit/cli").KeyValuePair[];
|
|
42
|
+
"where-neq": readonly import("@konstit/cli").KeyValuePair[];
|
|
43
|
+
"where-in": readonly import("@konstit/cli").KeyValuePair[];
|
|
44
|
+
"where-noin": readonly import("@konstit/cli").KeyValuePair[];
|
|
45
|
+
"where-prefix": readonly import("@konstit/cli").KeyValuePair[];
|
|
46
|
+
"where-regex": readonly import("@konstit/cli").KeyValuePair[];
|
|
47
|
+
json: boolean;
|
|
48
|
+
"output-delimiter": string;
|
|
49
|
+
limit: number | undefined;
|
|
50
|
+
}, {}, false, "filters" | "zip-limits" | "schema">;
|
|
51
|
+
export type CountArguments = Infer<typeof count>;
|
|
52
|
+
export type LinesArguments = Infer<typeof lines>;
|
|
53
|
+
export declare const csvCommand: import("@konstit/cli").HandledCommand<"csv", {}, {
|
|
54
|
+
count: import("@konstit/cli").HandledCommand<"count", {
|
|
55
|
+
path: string;
|
|
56
|
+
"zip-entry": string | undefined;
|
|
57
|
+
delimiter: string | undefined;
|
|
58
|
+
encoding: "utf8" | "utf-16le" | "latin1" | "ibm866" | "iso-8859-2" | "iso-8859-3" | "iso-8859-4" | "iso-8859-5" | "iso-8859-6" | "iso-8859-7" | "iso-8859-8" | "iso-8859-8-i" | "iso-8859-10" | "iso-8859-13" | "iso-8859-14" | "iso-8859-15" | "iso-8859-16" | "koi8-r" | "koi8-u" | "macintosh" | "windows-874" | "windows-1250" | "windows-1251" | "windows-1252" | "windows-1253" | "windows-1254" | "windows-1255" | "windows-1256" | "windows-1257" | "windows-1258" | "x-mac-cyrillic" | "gbk" | "gb18030" | "big5" | "euc-jp" | "iso-2022-jp" | "shift_jis" | "euc-kr" | "utf-16be" | "x-user-defined" | "auto" | undefined;
|
|
59
|
+
compression: "auto" | "zip" | "gzip" | "deflate" | "deflate-raw" | "brotli" | "zstd" | "none" | undefined;
|
|
60
|
+
"chunk-size": number | undefined;
|
|
61
|
+
"max-compression-ratio": number | undefined;
|
|
62
|
+
"max-decompressed-bytes": number | undefined;
|
|
63
|
+
strict: boolean;
|
|
64
|
+
"fixed-columns": number | undefined;
|
|
65
|
+
columns: string | undefined;
|
|
66
|
+
"expected-header": readonly string[];
|
|
67
|
+
"require-header": boolean;
|
|
68
|
+
"min-data-rows": number | undefined;
|
|
69
|
+
where: unknown;
|
|
70
|
+
"where-eq": readonly import("@konstit/cli").KeyValuePair[];
|
|
71
|
+
"where-neq": readonly import("@konstit/cli").KeyValuePair[];
|
|
72
|
+
"where-in": readonly import("@konstit/cli").KeyValuePair[];
|
|
73
|
+
"where-noin": readonly import("@konstit/cli").KeyValuePair[];
|
|
74
|
+
"where-prefix": readonly import("@konstit/cli").KeyValuePair[];
|
|
75
|
+
"where-regex": readonly import("@konstit/cli").KeyValuePair[];
|
|
76
|
+
}, {}, false, "filters" | "zip-limits" | "schema">;
|
|
77
|
+
lines: import("@konstit/cli").HandledCommand<"lines", {
|
|
78
|
+
path: string;
|
|
79
|
+
"zip-entry": string | undefined;
|
|
80
|
+
delimiter: string | undefined;
|
|
81
|
+
encoding: "utf8" | "utf-16le" | "latin1" | "ibm866" | "iso-8859-2" | "iso-8859-3" | "iso-8859-4" | "iso-8859-5" | "iso-8859-6" | "iso-8859-7" | "iso-8859-8" | "iso-8859-8-i" | "iso-8859-10" | "iso-8859-13" | "iso-8859-14" | "iso-8859-15" | "iso-8859-16" | "koi8-r" | "koi8-u" | "macintosh" | "windows-874" | "windows-1250" | "windows-1251" | "windows-1252" | "windows-1253" | "windows-1254" | "windows-1255" | "windows-1256" | "windows-1257" | "windows-1258" | "x-mac-cyrillic" | "gbk" | "gb18030" | "big5" | "euc-jp" | "iso-2022-jp" | "shift_jis" | "euc-kr" | "utf-16be" | "x-user-defined" | "auto" | undefined;
|
|
82
|
+
compression: "auto" | "zip" | "gzip" | "deflate" | "deflate-raw" | "brotli" | "zstd" | "none" | undefined;
|
|
83
|
+
"chunk-size": number | undefined;
|
|
84
|
+
"max-compression-ratio": number | undefined;
|
|
85
|
+
"max-decompressed-bytes": number | undefined;
|
|
86
|
+
strict: boolean;
|
|
87
|
+
"fixed-columns": number | undefined;
|
|
88
|
+
columns: string | undefined;
|
|
89
|
+
"expected-header": readonly string[];
|
|
90
|
+
"require-header": boolean;
|
|
91
|
+
"min-data-rows": number | undefined;
|
|
92
|
+
where: unknown;
|
|
93
|
+
"where-eq": readonly import("@konstit/cli").KeyValuePair[];
|
|
94
|
+
"where-neq": readonly import("@konstit/cli").KeyValuePair[];
|
|
95
|
+
"where-in": readonly import("@konstit/cli").KeyValuePair[];
|
|
96
|
+
"where-noin": readonly import("@konstit/cli").KeyValuePair[];
|
|
97
|
+
"where-prefix": readonly import("@konstit/cli").KeyValuePair[];
|
|
98
|
+
"where-regex": readonly import("@konstit/cli").KeyValuePair[];
|
|
99
|
+
json: boolean;
|
|
100
|
+
"output-delimiter": string;
|
|
101
|
+
limit: number | undefined;
|
|
102
|
+
}, {}, false, "filters" | "zip-limits" | "schema">;
|
|
103
|
+
probe: import("@konstit/cli").HandledCommand<"probe", {
|
|
104
|
+
path: string;
|
|
105
|
+
"zip-entry": string | undefined;
|
|
106
|
+
}, {}, boolean, string>;
|
|
107
|
+
completion: import("@konstit/cli").HandledCommand<"completion", {
|
|
108
|
+
shell: "bash" | "zsh" | "fish" | "powershell";
|
|
109
|
+
}, {}, boolean, string>;
|
|
110
|
+
}, true, string>;
|
|
111
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import {
|
|
2
|
+
command,
|
|
3
|
+
completionShells,
|
|
4
|
+
flag,
|
|
5
|
+
option,
|
|
6
|
+
parsers,
|
|
7
|
+
positional
|
|
8
|
+
} from "@konstit/cli";
|
|
9
|
+
import packageInfo from "../package.json";
|
|
10
|
+
import { resolveInputEncoding } from "./normalize.js";
|
|
11
|
+
const encodings = parsers.enum([
|
|
12
|
+
"auto",
|
|
13
|
+
{ value: "utf8", aliases: ["utf-8"] },
|
|
14
|
+
{ value: "latin1", aliases: ["iso88591", "iso-8859-1"] },
|
|
15
|
+
"utf-16le",
|
|
16
|
+
"utf-16be",
|
|
17
|
+
"windows-874",
|
|
18
|
+
"windows-1250",
|
|
19
|
+
"windows-1251",
|
|
20
|
+
{ value: "windows-1252", aliases: ["cp1252"] },
|
|
21
|
+
"windows-1253",
|
|
22
|
+
"windows-1254",
|
|
23
|
+
"windows-1255",
|
|
24
|
+
"windows-1256",
|
|
25
|
+
"windows-1257",
|
|
26
|
+
"windows-1258",
|
|
27
|
+
"iso-8859-2",
|
|
28
|
+
"iso-8859-3",
|
|
29
|
+
"iso-8859-4",
|
|
30
|
+
"iso-8859-5",
|
|
31
|
+
"iso-8859-6",
|
|
32
|
+
"iso-8859-7",
|
|
33
|
+
"iso-8859-8",
|
|
34
|
+
"iso-8859-8-i",
|
|
35
|
+
"iso-8859-10",
|
|
36
|
+
"iso-8859-13",
|
|
37
|
+
"iso-8859-14",
|
|
38
|
+
"iso-8859-15",
|
|
39
|
+
"iso-8859-16",
|
|
40
|
+
"big5",
|
|
41
|
+
"euc-jp",
|
|
42
|
+
"euc-kr",
|
|
43
|
+
"gb18030",
|
|
44
|
+
"gbk",
|
|
45
|
+
"ibm866",
|
|
46
|
+
"iso-2022-jp",
|
|
47
|
+
"koi8-r",
|
|
48
|
+
"koi8-u",
|
|
49
|
+
"macintosh",
|
|
50
|
+
{ value: "shift_jis", aliases: ["sjis"] },
|
|
51
|
+
"x-mac-cyrillic",
|
|
52
|
+
"x-user-defined"
|
|
53
|
+
]);
|
|
54
|
+
const encodingParser = {
|
|
55
|
+
...encodings,
|
|
56
|
+
parse(label) {
|
|
57
|
+
try {
|
|
58
|
+
return encodings.parse(label);
|
|
59
|
+
} catch {
|
|
60
|
+
const encoding = resolveInputEncoding(label);
|
|
61
|
+
return encodings.parse(typeof encoding === "string" ? encoding : encoding.encoding);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const compressionFormats = ["auto", "none", "gzip", "deflate", "deflate-raw", "brotli", "zstd", "zip"];
|
|
66
|
+
const positiveUint32 = parsers.range(1, 4294967295, { integer: !0 });
|
|
67
|
+
const byteSize = parsers.custom(parsers.byteSize.label, (input) => {
|
|
68
|
+
const bare = Number(input);
|
|
69
|
+
return parsers.byteSize.parse(Number.isNaN(bare) ? input : `${bare}B`);
|
|
70
|
+
});
|
|
71
|
+
const positiveByteSize = parsers.refine(byteSize, (bytes) => bytes > 0, "expected at least 1 byte");
|
|
72
|
+
const chunkSize = parsers.refine(positiveByteSize, (bytes) => bytes <= 67108864, "expected at most 64 MiB");
|
|
73
|
+
const inputDelimiter = parsers.regex(/^(?:auto|[\p{ASCII}--["\r\n]])$/v);
|
|
74
|
+
const outputDelimiter = parsers.regex(/^[\p{ASCII}--["\r\n]]$/v);
|
|
75
|
+
const path = positional("path", parsers.string, { required: !0, valueHint: "file", describe: "Input file path" });
|
|
76
|
+
const zipEntry = option("zip-entry", parsers.refine(parsers.string, (value) => value.length > 0, "expected a non-empty ZIP entry name"), {
|
|
77
|
+
valueName: "PATH",
|
|
78
|
+
describe: "Select an entry inside a ZIP archive"
|
|
79
|
+
});
|
|
80
|
+
const fileArgs = [
|
|
81
|
+
path,
|
|
82
|
+
option("delimiter", inputDelimiter, { valueName: "CHAR|auto", describe: "One safe ASCII character or auto (default: auto)" }),
|
|
83
|
+
option("encoding", encodingParser, {
|
|
84
|
+
valueName: "ENCODING",
|
|
85
|
+
describe: "Input encoding or decoder alias (default: auto)"
|
|
86
|
+
}),
|
|
87
|
+
option("compression", parsers.enum(compressionFormats), {
|
|
88
|
+
valueName: "FORMAT",
|
|
89
|
+
describe: `Input compression (default: auto). Choices: ${compressionFormats.join(", ")}`
|
|
90
|
+
}),
|
|
91
|
+
option("chunk-size", chunkSize, {
|
|
92
|
+
describe: "Read 1 B through 64 MiB per chunk (default: 1MiB). Example: 256KiB"
|
|
93
|
+
}),
|
|
94
|
+
zipEntry,
|
|
95
|
+
option("max-compression-ratio", positiveUint32, {
|
|
96
|
+
valueName: "RATIO",
|
|
97
|
+
describe: "Maximum ZIP expansion ratio, an integer from 1 through 4294967295"
|
|
98
|
+
}),
|
|
99
|
+
option("max-decompressed-bytes", positiveByteSize, { describe: "Maximum decompressed ZIP size (default: 64GiB)" }),
|
|
100
|
+
flag("strict", { describe: "Enable strict RFC 4180 validation" }),
|
|
101
|
+
option("fixed-columns", positiveUint32, { valueName: "COUNT", describe: "Require this positive field count in strict mode" }),
|
|
102
|
+
option("columns", parsers.string, {
|
|
103
|
+
valueName: "INDEXES",
|
|
104
|
+
describe: "Zero-based column indexes in output order. The count command validates the indexes only"
|
|
105
|
+
}),
|
|
106
|
+
option("expected-header", parsers.string, { repeatable: !0, describe: "Expected header value. Repeat once per column in strict mode" }),
|
|
107
|
+
flag("require-header", { describe: "Require a header row in strict mode" }),
|
|
108
|
+
option("min-data-rows", parsers.range(0, Number.MAX_SAFE_INTEGER, { integer: !0 }), {
|
|
109
|
+
valueName: "COUNT",
|
|
110
|
+
describe: "Require at least this many data rows in strict mode"
|
|
111
|
+
}),
|
|
112
|
+
option("where", parsers.json(), { valueName: "JSON", describe: "Advanced JSON can nest all, any, and not." }),
|
|
113
|
+
option("where-eq", parsers.keyValue, { repeatable: !0, valueName: "COLUMN=VALUE", describe: "Match an exact value" }),
|
|
114
|
+
option("where-neq", parsers.keyValue, { repeatable: !0, valueName: "COLUMN=VALUE", describe: "Exclude an exact value" }),
|
|
115
|
+
option("where-in", parsers.keyValue, { repeatable: !0, valueName: "COLUMN=VALUE", describe: "Match any listed value for this column" }),
|
|
116
|
+
option("where-noin", parsers.keyValue, {
|
|
117
|
+
repeatable: !0,
|
|
118
|
+
valueName: "COLUMN=VALUE",
|
|
119
|
+
describe: "Exclude all listed values for this column"
|
|
120
|
+
}),
|
|
121
|
+
option("where-prefix", parsers.keyValue, { repeatable: !0, valueName: "COLUMN=VALUE", describe: "Match a value prefix" }),
|
|
122
|
+
option("where-regex", parsers.keyValue, {
|
|
123
|
+
repeatable: !0,
|
|
124
|
+
valueName: "COLUMN=/RE/FLAGS",
|
|
125
|
+
describe: "Match an RE2-compatible regex (flags: i, m, s, u)"
|
|
126
|
+
})
|
|
127
|
+
];
|
|
128
|
+
const fileRelations = {
|
|
129
|
+
requires: [["zip-entry", "compression"]],
|
|
130
|
+
requiresIf: [["compression", "zip", "zip-entry"]],
|
|
131
|
+
groups: [
|
|
132
|
+
{
|
|
133
|
+
name: "zip-limits",
|
|
134
|
+
members: ["max-compression-ratio", "max-decompressed-bytes"],
|
|
135
|
+
multiple: !0,
|
|
136
|
+
requires: ["zip-entry"]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "schema",
|
|
140
|
+
members: ["fixed-columns", "expected-header", "require-header", "min-data-rows"],
|
|
141
|
+
multiple: !0,
|
|
142
|
+
requires: ["strict"]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "filters",
|
|
146
|
+
members: ["where", "where-eq", "where-neq", "where-in", "where-noin", "where-prefix", "where-regex"],
|
|
147
|
+
multiple: !0,
|
|
148
|
+
conflicts: ["strict"]
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
};
|
|
152
|
+
const fileHelp = `ZIP input automatically selects the only data file, ignoring OS metadata.
|
|
153
|
+
Explicit ZIP options require --compression zip and --zip-entry.
|
|
154
|
+
Filters use original input column indexes. Friendly filter clauses use AND.
|
|
155
|
+
Strict mode cannot use filter options.
|
|
156
|
+
|
|
157
|
+
Encodings: ${encodings.choices?.map(({ value, aliases }) => aliases ? `${value} (${aliases.join(", ")})` : value).join(", ")}
|
|
158
|
+
Other Bun TextDecoder labels are also accepted.`;
|
|
159
|
+
const count = command("count", {
|
|
160
|
+
...fileRelations,
|
|
161
|
+
about: "Count CSV records, including the header row",
|
|
162
|
+
args: fileArgs,
|
|
163
|
+
argsOverrideSelf: !0,
|
|
164
|
+
afterHelp: `${fileHelp}
|
|
165
|
+
|
|
166
|
+
Examples:
|
|
167
|
+
csv count data.csv --chunk-size 256KiB
|
|
168
|
+
csv count data.csv --where-eq 2=SP
|
|
169
|
+
csv count data.csv --where-regex '1=/^ana/i'`
|
|
170
|
+
});
|
|
171
|
+
const lines = command("lines", {
|
|
172
|
+
...fileRelations,
|
|
173
|
+
conflicts: [["json", "output-delimiter"], ["limit", "min-data-rows"]],
|
|
174
|
+
about: "Stream matching records as normalized UTF-8 CSV or NDJSON",
|
|
175
|
+
args: [
|
|
176
|
+
...fileArgs,
|
|
177
|
+
flag("json", { describe: "Emit one JSON string array per record (NDJSON)" }),
|
|
178
|
+
option("output-delimiter", outputDelimiter, {
|
|
179
|
+
valueName: "CHAR",
|
|
180
|
+
default: ",",
|
|
181
|
+
describe: "One safe ASCII output delimiter (default: comma). Incompatible with --json"
|
|
182
|
+
}),
|
|
183
|
+
option("limit", parsers.range(1, Number.MAX_SAFE_INTEGER, { integer: !0 }), {
|
|
184
|
+
valueName: "N",
|
|
185
|
+
describe: "Stop after matching output record N, numbered from 1. Incompatible with --min-data-rows"
|
|
186
|
+
})
|
|
187
|
+
],
|
|
188
|
+
argsOverrideSelf: !0,
|
|
189
|
+
afterHelp: `${fileHelp}
|
|
190
|
+
|
|
191
|
+
With --strict and --limit, validation stops at the selected record. Set a fixed
|
|
192
|
+
delimiter and encoding (defaults: comma and UTF-8). Input must be uncompressed
|
|
193
|
+
and the chunk size must be 1 byte. Earlier records can be written before a later error.
|
|
194
|
+
|
|
195
|
+
Examples:
|
|
196
|
+
csv lines data.csv --json --limit 10
|
|
197
|
+
csv lines data.csv --columns 0,2 --where-eq 3=active`
|
|
198
|
+
});
|
|
199
|
+
export const csvCommand = command("csv", {
|
|
200
|
+
about: "Inspect, count, and stream CSV records",
|
|
201
|
+
version: packageInfo.version,
|
|
202
|
+
defaultToHelp: !0,
|
|
203
|
+
subcommandRequired: !0,
|
|
204
|
+
subcommands: [
|
|
205
|
+
count,
|
|
206
|
+
lines,
|
|
207
|
+
command("probe", {
|
|
208
|
+
about: "Inspect file size, compression, encoding, delimiter, line endings, and first record width",
|
|
209
|
+
args: [path, zipEntry],
|
|
210
|
+
argsOverrideSelf: !0,
|
|
211
|
+
afterHelp: "Samples up to 64 KiB of CSV. For a ZIP archive with multiple data files, select one with --zip-entry."
|
|
212
|
+
}),
|
|
213
|
+
command("completion", {
|
|
214
|
+
about: "Print a shell completion script for csv",
|
|
215
|
+
args: [positional("shell", parsers.enum(completionShells), { required: !0, describe: completionShells.join(", ") })]
|
|
216
|
+
})
|
|
217
|
+
],
|
|
218
|
+
afterHelp: "Run without installing: bunx @konstit/csv <command> <path>"
|
|
219
|
+
});
|