@dra2020/baseclient 1.0.136 → 1.0.138
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/dist/baseclient.js +49 -1
- package/dist/baseclient.js.map +1 -1
- package/dist/csv/all.d.ts +1 -0
- package/dist/csv/csvparseline.d.ts +1 -0
- package/lib/csv/all.ts +1 -0
- package/lib/csv/csvparseline.ts +35 -0
- package/lib/filterexpr/filterexpr.ts +8 -1
- package/package.json +1 -1
package/dist/csv/all.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function csvParseLine(s: string): string[];
|
package/lib/csv/all.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const reField = /^\s*("([^"]*(?:""[^"]*)*)"|[^,|]*)\s*[|,]?/;
|
|
2
|
+
const reQuote = /^"/;
|
|
3
|
+
const reAddOne = /[|,]$/;
|
|
4
|
+
|
|
5
|
+
export function csvParseLine(s: string): string[]
|
|
6
|
+
{
|
|
7
|
+
let fields: string[] = [];
|
|
8
|
+
|
|
9
|
+
s = s.trim();
|
|
10
|
+
let addOne = reAddOne.test(s);
|
|
11
|
+
while (s)
|
|
12
|
+
{
|
|
13
|
+
const match = reField.exec(s);
|
|
14
|
+
if (match)
|
|
15
|
+
{
|
|
16
|
+
let field = match[1];
|
|
17
|
+
if (reQuote.test(field))
|
|
18
|
+
{
|
|
19
|
+
// if quoted string, convert quoted double-quotes to single quote
|
|
20
|
+
field = field.slice(1, -1).replace(/""/g, '"');
|
|
21
|
+
// and remove optional start and end double quote
|
|
22
|
+
field = field.replace(/^["]?/, '').replace(/["]?$/, '');
|
|
23
|
+
}
|
|
24
|
+
fields.push(field);
|
|
25
|
+
s = s.substring(match[0].length);
|
|
26
|
+
}
|
|
27
|
+
else
|
|
28
|
+
s = null;
|
|
29
|
+
}
|
|
30
|
+
// Handle trailing separator
|
|
31
|
+
if (addOne)
|
|
32
|
+
fields.push('');
|
|
33
|
+
return fields;
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -32,6 +32,13 @@ function isWhite(c: number): boolean
|
|
|
32
32
|
return c === Space || c === Newline || c === Tab || c == CR;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function toString(a: any): string
|
|
36
|
+
{
|
|
37
|
+
if (typeof a === 'object' && a && typeof a.value === 'string')
|
|
38
|
+
return a.value;
|
|
39
|
+
return String(a);
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
enum TokType
|
|
36
43
|
{
|
|
37
44
|
Text,
|
|
@@ -637,7 +644,7 @@ export class FilterExpr
|
|
|
637
644
|
case TokType.Text:
|
|
638
645
|
for (let p in o) if (o.hasOwnProperty(p) && (prop == null || p.toLowerCase() === prop))
|
|
639
646
|
{
|
|
640
|
-
let s =
|
|
647
|
+
let s = toString(o[p]);
|
|
641
648
|
if (s)
|
|
642
649
|
{
|
|
643
650
|
let t = types ? types[p] : undefined;
|