@dpuse/dpuse-tool-adaltas-csv-parser 1.0.118 → 1.0.120
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.
|
@@ -2900,7 +2900,7 @@ var Tr = {
|
|
|
2900
2900
|
status: /* @__PURE__ */ Z(Cr),
|
|
2901
2901
|
statusId: /* @__PURE__ */ Z(Sr)
|
|
2902
2902
|
};
|
|
2903
|
-
({ ...Tr }), J({ en: "Arrow" }), J({ en: "Avro" }), J({ en: "Delimited text (CSV,
|
|
2903
|
+
({ ...Tr }), J({ en: "Arrow" }), J({ en: "Avro" }), J({ en: "Delimited text (CSV, TSV…)" }), J({ en: "JSON" }), J({ en: "JSON Lines (JSONL)" }), J({ en: "Markdown (MD)" }), J({ en: "OpenDocument spreadsheet (ODS)" }), J({ en: "Parquet" }), J({ en: "SPSS (SAV)" }), J({ en: "SQLite" }), J({ en: "Excel (XLSX, XLSM)" }), J({ en: "XML" }), J({ en: "Newline" }), J({ en: "Carriage Return" }), J({ en: "Carriage Return/Newline" }), J({ en: "Colon" }), J({ en: "Comma" }), J({ en: "Exclamation Mark" }), J({ en: "Record Separator" }), J({ en: "Semicolon" }), J({ en: "Space" }), J({ en: "Tab" }), J({ en: "Underscore" }), J({ en: "Unit Separator" }), J({ en: "Vertical Bar" }), $([
|
|
2904
2904
|
"app",
|
|
2905
2905
|
"engine",
|
|
2906
2906
|
"connector",
|
|
@@ -2950,48 +2950,87 @@ var Er = {
|
|
|
2950
2950
|
"disabled",
|
|
2951
2951
|
"oAuth2",
|
|
2952
2952
|
"none"
|
|
2953
|
-
]), { ...Er }
|
|
2954
|
-
|
|
2955
|
-
data;
|
|
2956
|
-
locator;
|
|
2957
|
-
constructor(e, t, n, r) {
|
|
2958
|
-
super(e, r), this.name = "DPUseError", this.data = n, this.locator = t;
|
|
2959
|
-
}
|
|
2960
|
-
}, kr = class extends Or {
|
|
2961
|
-
constructor(e, t, n, r) {
|
|
2962
|
-
super(e, t, n, r), this.name = "FetchError";
|
|
2963
|
-
}
|
|
2964
|
-
};
|
|
2965
|
-
async function Ar(e, t, n) {
|
|
2966
|
-
let r = ` - ${e.statusText}`, i = `${t} Response status '${String(e.status)}${e.statusText ? r : ""}' received.`, a;
|
|
2967
|
-
try {
|
|
2968
|
-
a = await e.text();
|
|
2969
|
-
} catch (e) {
|
|
2970
|
-
a = `<body unavailable: ${Mr(e).message}>`;
|
|
2971
|
-
}
|
|
2972
|
-
return new kr(i, n, { body: Nr(a) });
|
|
2973
|
-
}
|
|
2974
|
-
function jr(e) {
|
|
2953
|
+
]), { ...Er };
|
|
2954
|
+
function Dr(e) {
|
|
2975
2955
|
try {
|
|
2976
2956
|
e();
|
|
2977
2957
|
} catch {}
|
|
2978
2958
|
}
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2959
|
+
$([
|
|
2960
|
+
"arrow",
|
|
2961
|
+
"avro",
|
|
2962
|
+
"dtv",
|
|
2963
|
+
"json",
|
|
2964
|
+
"jsonl",
|
|
2965
|
+
"markdown",
|
|
2966
|
+
"ods",
|
|
2967
|
+
"parquet",
|
|
2968
|
+
"sav",
|
|
2969
|
+
"sqlite",
|
|
2970
|
+
"xlsx",
|
|
2971
|
+
"xml"
|
|
2972
|
+
]), { ...Er };
|
|
2973
|
+
async function Or(e, t, n) {
|
|
2974
|
+
let r = kr(e), { issues: i, parsedRecords: a, valueDelimiterId: o } = await Ar(e, t.valueDelimiterIds, t.isComplete, n);
|
|
2975
|
+
return {
|
|
2976
|
+
issues: i,
|
|
2977
|
+
parsedRecords: a,
|
|
2978
|
+
recordDelimiterId: r,
|
|
2979
|
+
valueDelimiterId: o
|
|
2980
|
+
};
|
|
2981
|
+
}
|
|
2982
|
+
function kr(e) {
|
|
2983
|
+
let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
|
|
2984
|
+
return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
|
|
2985
|
+
}
|
|
2986
|
+
async function Ar(e, t, n, r) {
|
|
2987
|
+
let i, a, o, s = [], c, l = !1;
|
|
2988
|
+
for (let u of t) {
|
|
2989
|
+
let { issues: t, records: d } = await r(e, u, n);
|
|
2990
|
+
if (t.length > 0) {
|
|
2991
|
+
c = jr(c, {
|
|
2992
|
+
delimiter: u,
|
|
2993
|
+
issues: t,
|
|
2994
|
+
records: d
|
|
2995
|
+
});
|
|
2996
|
+
continue;
|
|
2997
|
+
}
|
|
2998
|
+
if (l = !0, d.length === 0) continue;
|
|
2999
|
+
let { averageValueCount: f, sumOfValueCountDiffs: p } = Mr(d);
|
|
3000
|
+
(!o || p <= o) && (!a || f > a) && (i = u, a = f, o = p, s = d);
|
|
3001
|
+
}
|
|
3002
|
+
if (!l && c != null) {
|
|
3003
|
+
let { delimiter: e, issues: t, records: n } = c;
|
|
3004
|
+
return {
|
|
3005
|
+
issues: t,
|
|
3006
|
+
parsedRecords: n,
|
|
3007
|
+
valueDelimiterId: Nr(n) ? e : void 0
|
|
3008
|
+
};
|
|
2988
3009
|
}
|
|
2989
|
-
return
|
|
3010
|
+
return {
|
|
3011
|
+
issues: [],
|
|
3012
|
+
parsedRecords: s,
|
|
3013
|
+
valueDelimiterId: i != null && Nr(s) ? i : void 0
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
3016
|
+
function jr(e, t) {
|
|
3017
|
+
return e == null || t.issues.length < e.issues.length ? t : e;
|
|
3018
|
+
}
|
|
3019
|
+
function Mr(e) {
|
|
3020
|
+
let t = 0, n = 0, r;
|
|
3021
|
+
for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
|
|
3022
|
+
return {
|
|
3023
|
+
averageValueCount: t / e.length,
|
|
3024
|
+
sumOfValueCountDiffs: n
|
|
3025
|
+
};
|
|
2990
3026
|
}
|
|
2991
3027
|
function Nr(e) {
|
|
2992
|
-
|
|
3028
|
+
let t = /* @__PURE__ */ new Map();
|
|
3029
|
+
for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
|
|
3030
|
+
let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
|
|
3031
|
+
return n > 1 && r * 2 > e.length;
|
|
2993
3032
|
}
|
|
2994
|
-
$([
|
|
3033
|
+
$(["list"]), { ...Er }, $([
|
|
2995
3034
|
"list",
|
|
2996
3035
|
"render",
|
|
2997
3036
|
"setColorMode"
|
|
@@ -3002,8 +3041,8 @@ var Pr = {
|
|
|
3002
3041
|
groupId: null,
|
|
3003
3042
|
decoderId: "windows-1252"
|
|
3004
3043
|
},
|
|
3005
|
-
|
|
3006
|
-
id: "
|
|
3044
|
+
big5: {
|
|
3045
|
+
id: "big5",
|
|
3007
3046
|
groupId: "chineseTraditional",
|
|
3008
3047
|
decoderId: "big5"
|
|
3009
3048
|
},
|
|
@@ -3102,8 +3141,8 @@ var Pr = {
|
|
|
3102
3141
|
groupId: "greek",
|
|
3103
3142
|
decoderId: null
|
|
3104
3143
|
},
|
|
3105
|
-
|
|
3106
|
-
id: "
|
|
3144
|
+
cp874: {
|
|
3145
|
+
id: "cp874",
|
|
3107
3146
|
groupId: "thai",
|
|
3108
3147
|
decoderId: "windows-874"
|
|
3109
3148
|
},
|
|
@@ -3112,13 +3151,13 @@ var Pr = {
|
|
|
3112
3151
|
groupId: "greek",
|
|
3113
3152
|
decoderId: null
|
|
3114
3153
|
},
|
|
3115
|
-
|
|
3116
|
-
id: "
|
|
3154
|
+
cp932: {
|
|
3155
|
+
id: "cp932",
|
|
3117
3156
|
groupId: "japanese",
|
|
3118
3157
|
decoderId: "shift_jis"
|
|
3119
3158
|
},
|
|
3120
|
-
|
|
3121
|
-
id: "
|
|
3159
|
+
cp949: {
|
|
3160
|
+
id: "cp949",
|
|
3122
3161
|
groupId: "korean",
|
|
3123
3162
|
decoderId: "euc-kr"
|
|
3124
3163
|
},
|
|
@@ -3147,18 +3186,18 @@ var Pr = {
|
|
|
3147
3186
|
groupId: "vietnamese",
|
|
3148
3187
|
decoderId: "windows-1258"
|
|
3149
3188
|
},
|
|
3150
|
-
"
|
|
3151
|
-
id: "
|
|
3189
|
+
"euc-jp": {
|
|
3190
|
+
id: "euc-jp",
|
|
3152
3191
|
groupId: "japanese",
|
|
3153
3192
|
decoderId: "euc-jp"
|
|
3154
3193
|
},
|
|
3155
|
-
"
|
|
3156
|
-
id: "
|
|
3194
|
+
"euc-kr": {
|
|
3195
|
+
id: "euc-kr",
|
|
3157
3196
|
groupId: "korean",
|
|
3158
3197
|
decoderId: "euc-kr"
|
|
3159
3198
|
},
|
|
3160
|
-
|
|
3161
|
-
id: "
|
|
3199
|
+
gb18030: {
|
|
3200
|
+
id: "gb18030",
|
|
3162
3201
|
groupId: "chineseSimplified",
|
|
3163
3202
|
decoderId: "gb18030"
|
|
3164
3203
|
},
|
|
@@ -3167,68 +3206,68 @@ var Pr = {
|
|
|
3167
3206
|
groupId: "western",
|
|
3168
3207
|
decoderId: null
|
|
3169
3208
|
},
|
|
3170
|
-
"
|
|
3171
|
-
id: "
|
|
3209
|
+
"hz-gb-2312": {
|
|
3210
|
+
id: "hz-gb-2312",
|
|
3172
3211
|
groupId: "chineseSimplified",
|
|
3173
3212
|
decoderId: null
|
|
3174
3213
|
},
|
|
3175
|
-
|
|
3176
|
-
id: "
|
|
3214
|
+
ibm855: {
|
|
3215
|
+
id: "ibm855",
|
|
3177
3216
|
groupId: "cyrillic",
|
|
3178
3217
|
decoderId: null
|
|
3179
3218
|
},
|
|
3180
|
-
|
|
3181
|
-
id: "
|
|
3219
|
+
ibm866: {
|
|
3220
|
+
id: "ibm866",
|
|
3182
3221
|
groupId: "cyrillic",
|
|
3183
3222
|
decoderId: "ibm866"
|
|
3184
3223
|
},
|
|
3185
|
-
"
|
|
3186
|
-
id: "
|
|
3224
|
+
"iso-2022-jp": {
|
|
3225
|
+
id: "iso-2022-jp",
|
|
3187
3226
|
groupId: "japanese",
|
|
3188
3227
|
decoderId: "iso-2022-jp"
|
|
3189
3228
|
},
|
|
3190
|
-
"
|
|
3191
|
-
id: "
|
|
3229
|
+
"iso-2022-kr": {
|
|
3230
|
+
id: "iso-2022-kr",
|
|
3192
3231
|
groupId: "korean",
|
|
3193
3232
|
decoderId: null
|
|
3194
3233
|
},
|
|
3195
|
-
"
|
|
3196
|
-
id: "
|
|
3234
|
+
"iso-8859-1": {
|
|
3235
|
+
id: "iso-8859-1",
|
|
3197
3236
|
groupId: "western",
|
|
3198
3237
|
decoderId: "windows-1252"
|
|
3199
3238
|
},
|
|
3200
|
-
"
|
|
3201
|
-
id: "
|
|
3239
|
+
"iso-8859-2": {
|
|
3240
|
+
id: "iso-8859-2",
|
|
3202
3241
|
groupId: "centralEuropean",
|
|
3203
3242
|
decoderId: "iso-8859-2"
|
|
3204
3243
|
},
|
|
3205
|
-
"
|
|
3206
|
-
id: "
|
|
3244
|
+
"iso-8859-5": {
|
|
3245
|
+
id: "iso-8859-5",
|
|
3207
3246
|
groupId: "cyrillic",
|
|
3208
3247
|
decoderId: "iso-8859-5"
|
|
3209
3248
|
},
|
|
3210
|
-
"
|
|
3211
|
-
id: "
|
|
3249
|
+
"iso-8859-6": {
|
|
3250
|
+
id: "iso-8859-6",
|
|
3212
3251
|
groupId: "arabic",
|
|
3213
3252
|
decoderId: "iso-8859-6"
|
|
3214
3253
|
},
|
|
3215
|
-
"
|
|
3216
|
-
id: "
|
|
3254
|
+
"iso-8859-7": {
|
|
3255
|
+
id: "iso-8859-7",
|
|
3217
3256
|
groupId: "greek",
|
|
3218
3257
|
decoderId: "iso-8859-7"
|
|
3219
3258
|
},
|
|
3220
|
-
"
|
|
3221
|
-
id: "
|
|
3259
|
+
"iso-8859-8": {
|
|
3260
|
+
id: "iso-8859-8",
|
|
3222
3261
|
groupId: "hebrew",
|
|
3223
3262
|
decoderId: "iso-8859-8-i"
|
|
3224
3263
|
},
|
|
3225
|
-
"
|
|
3226
|
-
id: "
|
|
3264
|
+
"iso-8859-9": {
|
|
3265
|
+
id: "iso-8859-9",
|
|
3227
3266
|
groupId: "turkish",
|
|
3228
3267
|
decoderId: "windows-1254"
|
|
3229
3268
|
},
|
|
3230
|
-
"
|
|
3231
|
-
id: "
|
|
3269
|
+
"iso-8859-13": {
|
|
3270
|
+
id: "iso-8859-13",
|
|
3232
3271
|
groupId: "baltic",
|
|
3233
3272
|
decoderId: "iso-8859-13"
|
|
3234
3273
|
},
|
|
@@ -3272,13 +3311,13 @@ var Pr = {
|
|
|
3272
3311
|
groupId: "romanian",
|
|
3273
3312
|
decoderId: "iso-8859-16"
|
|
3274
3313
|
},
|
|
3275
|
-
|
|
3276
|
-
id: "
|
|
3314
|
+
johab: {
|
|
3315
|
+
id: "johab",
|
|
3277
3316
|
groupId: "korean",
|
|
3278
3317
|
decoderId: null
|
|
3279
3318
|
},
|
|
3280
|
-
"
|
|
3281
|
-
id: "
|
|
3319
|
+
"koi8-r": {
|
|
3320
|
+
id: "koi8-r",
|
|
3282
3321
|
groupId: "cyrillic",
|
|
3283
3322
|
decoderId: "koi8-r"
|
|
3284
3323
|
},
|
|
@@ -3292,38 +3331,38 @@ var Pr = {
|
|
|
3292
3331
|
groupId: "cyrillic",
|
|
3293
3332
|
decoderId: "koi8-u"
|
|
3294
3333
|
},
|
|
3295
|
-
|
|
3296
|
-
id: "
|
|
3334
|
+
kz1048: {
|
|
3335
|
+
id: "kz1048",
|
|
3297
3336
|
groupId: "cyrillic",
|
|
3298
3337
|
decoderId: null
|
|
3299
3338
|
},
|
|
3300
|
-
|
|
3301
|
-
id: "
|
|
3339
|
+
maccyrillic: {
|
|
3340
|
+
id: "maccyrillic",
|
|
3302
3341
|
groupId: "cyrillic",
|
|
3303
3342
|
decoderId: "x-mac-cyrillic"
|
|
3304
3343
|
},
|
|
3305
|
-
|
|
3306
|
-
id: "
|
|
3344
|
+
macgreek: {
|
|
3345
|
+
id: "macgreek",
|
|
3307
3346
|
groupId: "greek",
|
|
3308
3347
|
decoderId: null
|
|
3309
3348
|
},
|
|
3310
|
-
|
|
3311
|
-
id: "
|
|
3349
|
+
maciceland: {
|
|
3350
|
+
id: "maciceland",
|
|
3312
3351
|
groupId: "nordic",
|
|
3313
3352
|
decoderId: null
|
|
3314
3353
|
},
|
|
3315
|
-
|
|
3316
|
-
id: "
|
|
3354
|
+
maclatin2: {
|
|
3355
|
+
id: "maclatin2",
|
|
3317
3356
|
groupId: "centralEuropean",
|
|
3318
3357
|
decoderId: null
|
|
3319
3358
|
},
|
|
3320
|
-
|
|
3321
|
-
id: "
|
|
3359
|
+
macroman: {
|
|
3360
|
+
id: "macroman",
|
|
3322
3361
|
groupId: "western",
|
|
3323
3362
|
decoderId: "macintosh"
|
|
3324
3363
|
},
|
|
3325
|
-
|
|
3326
|
-
id: "
|
|
3364
|
+
macturkish: {
|
|
3365
|
+
id: "macturkish",
|
|
3327
3366
|
groupId: "turkish",
|
|
3328
3367
|
decoderId: null
|
|
3329
3368
|
},
|
|
@@ -3332,13 +3371,13 @@ var Pr = {
|
|
|
3332
3371
|
groupId: "cyrillic",
|
|
3333
3372
|
decoderId: null
|
|
3334
3373
|
},
|
|
3335
|
-
|
|
3336
|
-
id: "
|
|
3374
|
+
shift_jis: {
|
|
3375
|
+
id: "shift_jis",
|
|
3337
3376
|
groupId: "japanese",
|
|
3338
3377
|
decoderId: "shift_jis"
|
|
3339
3378
|
},
|
|
3340
|
-
"
|
|
3341
|
-
id: "
|
|
3379
|
+
"tis-620": {
|
|
3380
|
+
id: "tis-620",
|
|
3342
3381
|
groupId: "thai",
|
|
3343
3382
|
decoderId: "windows-874"
|
|
3344
3383
|
},
|
|
@@ -3352,13 +3391,13 @@ var Pr = {
|
|
|
3352
3391
|
groupId: null,
|
|
3353
3392
|
decoderId: "utf-8"
|
|
3354
3393
|
},
|
|
3355
|
-
"
|
|
3356
|
-
id: "
|
|
3394
|
+
"utf-8-sig": {
|
|
3395
|
+
id: "utf-8-sig",
|
|
3357
3396
|
groupId: null,
|
|
3358
3397
|
decoderId: "utf-8"
|
|
3359
3398
|
},
|
|
3360
|
-
"
|
|
3361
|
-
id: "
|
|
3399
|
+
"utf-16": {
|
|
3400
|
+
id: "utf-16",
|
|
3362
3401
|
groupId: "unicode16",
|
|
3363
3402
|
decoderId: null
|
|
3364
3403
|
},
|
|
@@ -3372,8 +3411,8 @@ var Pr = {
|
|
|
3372
3411
|
groupId: "unicode16",
|
|
3373
3412
|
decoderId: "utf-16le"
|
|
3374
3413
|
},
|
|
3375
|
-
"
|
|
3376
|
-
id: "
|
|
3414
|
+
"utf-32": {
|
|
3415
|
+
id: "utf-32",
|
|
3377
3416
|
groupId: "unicode32",
|
|
3378
3417
|
decoderId: null
|
|
3379
3418
|
},
|
|
@@ -3387,43 +3426,43 @@ var Pr = {
|
|
|
3387
3426
|
groupId: "unicode32",
|
|
3388
3427
|
decoderId: null
|
|
3389
3428
|
},
|
|
3390
|
-
"
|
|
3391
|
-
id: "
|
|
3429
|
+
"windows-1250": {
|
|
3430
|
+
id: "windows-1250",
|
|
3392
3431
|
groupId: "centralEuropean",
|
|
3393
3432
|
decoderId: "windows-1250"
|
|
3394
3433
|
},
|
|
3395
|
-
"
|
|
3396
|
-
id: "
|
|
3434
|
+
"windows-1251": {
|
|
3435
|
+
id: "windows-1251",
|
|
3397
3436
|
groupId: "cyrillic",
|
|
3398
3437
|
decoderId: "windows-1251"
|
|
3399
3438
|
},
|
|
3400
|
-
"
|
|
3401
|
-
id: "
|
|
3439
|
+
"windows-1252": {
|
|
3440
|
+
id: "windows-1252",
|
|
3402
3441
|
groupId: "western",
|
|
3403
3442
|
decoderId: "windows-1252"
|
|
3404
3443
|
},
|
|
3405
|
-
"
|
|
3406
|
-
id: "
|
|
3444
|
+
"windows-1253": {
|
|
3445
|
+
id: "windows-1253",
|
|
3407
3446
|
groupId: "greek",
|
|
3408
3447
|
decoderId: "windows-1253"
|
|
3409
3448
|
},
|
|
3410
|
-
"
|
|
3411
|
-
id: "
|
|
3449
|
+
"windows-1254": {
|
|
3450
|
+
id: "windows-1254",
|
|
3412
3451
|
groupId: "turkish",
|
|
3413
3452
|
decoderId: "windows-1254"
|
|
3414
3453
|
},
|
|
3415
|
-
"
|
|
3416
|
-
id: "
|
|
3454
|
+
"windows-1255": {
|
|
3455
|
+
id: "windows-1255",
|
|
3417
3456
|
groupId: "hebrew",
|
|
3418
3457
|
decoderId: "windows-1255"
|
|
3419
3458
|
},
|
|
3420
|
-
"
|
|
3421
|
-
id: "
|
|
3459
|
+
"windows-1256": {
|
|
3460
|
+
id: "windows-1256",
|
|
3422
3461
|
groupId: "arabic",
|
|
3423
3462
|
decoderId: "windows-1256"
|
|
3424
3463
|
},
|
|
3425
|
-
"
|
|
3426
|
-
id: "
|
|
3464
|
+
"windows-1257": {
|
|
3465
|
+
id: "windows-1257",
|
|
3427
3466
|
groupId: "baltic",
|
|
3428
3467
|
decoderId: "windows-1257"
|
|
3429
3468
|
}
|
|
@@ -3465,71 +3504,70 @@ var Lr = {
|
|
|
3465
3504
|
to_line: -1,
|
|
3466
3505
|
trim: !1
|
|
3467
3506
|
}, Rr = 4, zr = 50, Br = 1e4, Vr = class {
|
|
3468
|
-
async parseStream(e, t, n
|
|
3469
|
-
return new Promise((
|
|
3470
|
-
let
|
|
3471
|
-
if (
|
|
3472
|
-
|
|
3473
|
-
let e =
|
|
3474
|
-
|
|
3507
|
+
async parseStream(e, t, n) {
|
|
3508
|
+
return new Promise((r, i) => {
|
|
3509
|
+
let a, o, s, c = !1, l = !1, u = () => {
|
|
3510
|
+
if (l) return;
|
|
3511
|
+
l = !0;
|
|
3512
|
+
let e = a;
|
|
3513
|
+
a = void 0, s = void 0, e != null && (Dr(() => e.removeAllListeners()), Dr(() => e.end())), Dr(() => void o?.cancel()), o = void 0;
|
|
3514
|
+
}, d = (e) => {
|
|
3515
|
+
c || (c = !0, u(), i(e instanceof Error ? e : Error(String(e))));
|
|
3475
3516
|
};
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
(async () => {
|
|
3481
|
-
s = ar({
|
|
3517
|
+
t.abortSignal.addEventListener("abort", () => {
|
|
3518
|
+
d(t.abortSignal.reason);
|
|
3519
|
+
}, { once: !0 }), (async () => {
|
|
3520
|
+
t.abortSignal.throwIfAborted(), a = ar({
|
|
3482
3521
|
...Lr,
|
|
3483
|
-
...t,
|
|
3484
3522
|
cast: (e, t) => ({
|
|
3485
3523
|
value: e,
|
|
3486
|
-
|
|
3487
|
-
})
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3524
|
+
valueWasQuoted: t.quoting
|
|
3525
|
+
}),
|
|
3526
|
+
delimiter: t.valueDelimiterId,
|
|
3527
|
+
relax_column_count: !0
|
|
3528
|
+
}), s = Hr({
|
|
3529
|
+
chunk: n,
|
|
3530
|
+
chunkSize: t.chunkSize ?? Br
|
|
3531
|
+
}), a.on("readable", () => {
|
|
3492
3532
|
try {
|
|
3493
|
-
if (
|
|
3533
|
+
if (a == null || s == null) return;
|
|
3494
3534
|
let e;
|
|
3495
|
-
for (; (e =
|
|
3496
|
-
if (
|
|
3497
|
-
|
|
3535
|
+
for (; (e = a.read()) != null;) {
|
|
3536
|
+
if (c) return;
|
|
3537
|
+
t.abortSignal.throwIfAborted(), s.push(e);
|
|
3498
3538
|
}
|
|
3499
3539
|
} catch (e) {
|
|
3500
|
-
|
|
3540
|
+
d(e);
|
|
3501
3541
|
}
|
|
3502
|
-
}),
|
|
3503
|
-
|
|
3504
|
-
}),
|
|
3505
|
-
|
|
3506
|
-
});
|
|
3507
|
-
let
|
|
3508
|
-
if (!o.ok || o.body == null) throw await Ar(o, `Failed to fetch '${n}' file.`, "dpuse-connector-file-store-emulator|Connector|retrieve");
|
|
3509
|
-
c = o.body.getReader();
|
|
3510
|
-
let d = new TextDecoder(Ir(e.encodingId)), f = await c.read();
|
|
3542
|
+
}), a.on("error", (e) => {
|
|
3543
|
+
d(e);
|
|
3544
|
+
}), a.on("end", () => {
|
|
3545
|
+
c || (s?.flush(), r(Ur(a)));
|
|
3546
|
+
}), o = e.getReader();
|
|
3547
|
+
let i = new TextDecoder(Ir(t.encodingId)), l = 0, u = !1, f = await o.read();
|
|
3511
3548
|
for (; !f.done;) {
|
|
3512
|
-
if (
|
|
3513
|
-
|
|
3514
|
-
let e =
|
|
3515
|
-
e.length > 0 &&
|
|
3549
|
+
if (c) return;
|
|
3550
|
+
t.abortSignal.throwIfAborted(), l += f.value.length;
|
|
3551
|
+
let e = i.decode(f.value, { stream: !0 });
|
|
3552
|
+
e.length > 0 && (a.write(e), u = !0), f = await o.read();
|
|
3516
3553
|
}
|
|
3517
|
-
if (
|
|
3518
|
-
let
|
|
3519
|
-
|
|
3554
|
+
if (c) return;
|
|
3555
|
+
let p = i.decode();
|
|
3556
|
+
p.length > 0 && (a.write(p), u = !0), u ? a.end() : (a.removeAllListeners(), a = void 0, r({
|
|
3557
|
+
byteCount: l,
|
|
3558
|
+
commentLineCount: 0,
|
|
3559
|
+
emptyLineCount: 0,
|
|
3560
|
+
lineCount: 0,
|
|
3561
|
+
nonUniformRecordCount: 0,
|
|
3562
|
+
recordCount: 0
|
|
3563
|
+
}));
|
|
3520
3564
|
})().catch((e) => {
|
|
3521
|
-
|
|
3565
|
+
d(e);
|
|
3522
3566
|
});
|
|
3523
3567
|
});
|
|
3524
3568
|
}
|
|
3525
|
-
async parseText(e, t
|
|
3526
|
-
|
|
3527
|
-
return {
|
|
3528
|
-
issues: i,
|
|
3529
|
-
parsedRecords: a,
|
|
3530
|
-
recordDelimiterId: r,
|
|
3531
|
-
valueDelimiterId: o
|
|
3532
|
-
};
|
|
3569
|
+
async parseText(e, t) {
|
|
3570
|
+
return await Or(e, t, Wr);
|
|
3533
3571
|
}
|
|
3534
3572
|
};
|
|
3535
3573
|
function Hr(e) {
|
|
@@ -3561,52 +3599,15 @@ function Ur(e) {
|
|
|
3561
3599
|
recordCount: e?.info.records ?? -1
|
|
3562
3600
|
};
|
|
3563
3601
|
}
|
|
3564
|
-
function Wr(e) {
|
|
3565
|
-
let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
|
|
3566
|
-
return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
|
|
3567
|
-
}
|
|
3568
|
-
async function Gr(e, t, n) {
|
|
3569
|
-
let r, i, a, o = [], s, c = !1;
|
|
3570
|
-
for (let l of t) {
|
|
3571
|
-
let { issues: t, records: u } = await qr(e, l, n);
|
|
3572
|
-
if (t.length > 0) {
|
|
3573
|
-
s = Kr(s, {
|
|
3574
|
-
delimiter: l,
|
|
3575
|
-
issues: t,
|
|
3576
|
-
records: u
|
|
3577
|
-
});
|
|
3578
|
-
continue;
|
|
3579
|
-
}
|
|
3580
|
-
if (c = !0, u.length === 0) continue;
|
|
3581
|
-
let { averageValueCount: d, sumOfValueCountDiffs: f } = Yr(u);
|
|
3582
|
-
(!a || f <= a) && (!i || d > i) && (r = l, i = d, a = f, o = u);
|
|
3583
|
-
}
|
|
3584
|
-
if (!c && s != null) {
|
|
3585
|
-
let { delimiter: e, issues: t, records: n } = s;
|
|
3586
|
-
return {
|
|
3587
|
-
issues: t,
|
|
3588
|
-
parsedRecords: n,
|
|
3589
|
-
valueDelimiterId: Xr(n) ? e : void 0
|
|
3590
|
-
};
|
|
3591
|
-
}
|
|
3592
|
-
return {
|
|
3593
|
-
issues: [],
|
|
3594
|
-
parsedRecords: o,
|
|
3595
|
-
valueDelimiterId: r != null && Xr(o) ? r : void 0
|
|
3596
|
-
};
|
|
3597
|
-
}
|
|
3598
|
-
function Kr(e, t) {
|
|
3599
|
-
return e == null || t.issues.length < e.issues.length ? t : e;
|
|
3600
|
-
}
|
|
3601
|
-
function qr(e, t, n) {
|
|
3602
|
+
function Wr(e, t, n) {
|
|
3602
3603
|
return new Promise((r) => {
|
|
3603
3604
|
let i = [], a = [], o = 0, s = (e) => {
|
|
3604
|
-
e == null || !n && e.code === "CSV_QUOTE_NOT_CLOSED" || (i.push(
|
|
3605
|
+
e == null || !n && e.code === "CSV_QUOTE_NOT_CLOSED" || (i.push(Gr(e, o + 1)), e.lines != null && (o = e.lines));
|
|
3605
3606
|
}, c = ar({
|
|
3606
3607
|
...Lr,
|
|
3607
3608
|
cast: (e, t) => ({
|
|
3608
3609
|
value: e,
|
|
3609
|
-
|
|
3610
|
+
valueWasQuoted: t.quoting
|
|
3610
3611
|
}),
|
|
3611
3612
|
delimiter: t,
|
|
3612
3613
|
info: !0,
|
|
@@ -3631,7 +3632,7 @@ function qr(e, t, n) {
|
|
|
3631
3632
|
}), c.write(e), c.end();
|
|
3632
3633
|
});
|
|
3633
3634
|
}
|
|
3634
|
-
function
|
|
3635
|
+
function Gr(e, t) {
|
|
3635
3636
|
let n = e.lines, r = e.code === "CSV_INVALID_CLOSING_QUOTE" ? /got "(.*?)" at line/u.exec(e.message)?.[1] : void 0, i = typeof e.field == "string" ? e.field : r;
|
|
3636
3637
|
return {
|
|
3637
3638
|
endLineNumber: n != null && n > t ? n : void 0,
|
|
@@ -3644,18 +3645,4 @@ function Jr(e, t) {
|
|
|
3644
3645
|
value: i != null && i.length > zr ? `${i.slice(0, zr)}…` : i
|
|
3645
3646
|
};
|
|
3646
3647
|
}
|
|
3647
|
-
function Yr(e) {
|
|
3648
|
-
let t = 0, n = 0, r;
|
|
3649
|
-
for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
|
|
3650
|
-
return {
|
|
3651
|
-
averageValueCount: t / e.length,
|
|
3652
|
-
sumOfValueCountDiffs: n
|
|
3653
|
-
};
|
|
3654
|
-
}
|
|
3655
|
-
function Xr(e) {
|
|
3656
|
-
let t = /* @__PURE__ */ new Map();
|
|
3657
|
-
for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
|
|
3658
|
-
let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
|
|
3659
|
-
return n > 1 && r * 2 > e.length;
|
|
3660
|
-
}
|
|
3661
3648
|
export { Vr as Tool };
|