@maiyunnet/kebab 9.22.4 → 9.22.5
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/abox/master-log.d.ts +1 -0
- package/abox/master-log.js +26 -0
- package/abox/text.d.ts +2 -0
- package/abox/text.js +21 -0
- package/doc/kebab-rag.md +127 -103
- package/index.d.ts +7 -2
- package/index.js +1 -1
- package/lib/text.d.ts +6 -4
- package/lib/text.js +11 -34
- package/package.json +3 -2
- package/sys/master.js +185 -279
- package/sys/route.d.ts +5 -5
- package/sys/route.js +33 -20
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseCsvLine(line: string): string[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function parseCsvLine(line) {
|
|
2
|
+
const fields = [];
|
|
3
|
+
let field = '';
|
|
4
|
+
let quoted = false;
|
|
5
|
+
for (let i = 0; i < line.length; ++i) {
|
|
6
|
+
const char = line[i];
|
|
7
|
+
if (char === '"') {
|
|
8
|
+
if (quoted && line[i + 1] === '"') {
|
|
9
|
+
field += '"';
|
|
10
|
+
++i;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
quoted = !quoted;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else if (char === ',' && !quoted) {
|
|
17
|
+
fields.push(field);
|
|
18
|
+
field = '';
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
field += char;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
fields.push(field);
|
|
25
|
+
return fields;
|
|
26
|
+
}
|
package/abox/text.d.ts
ADDED
package/abox/text.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// TypeScript's bundled JSON declarations do not yet include these Node 22 APIs.
|
|
2
|
+
const nativeJson = JSON;
|
|
3
|
+
export function parseJson(str) {
|
|
4
|
+
try {
|
|
5
|
+
return nativeJson.parse(str, (_key, value, context) => {
|
|
6
|
+
if (typeof value === 'number' && !Number.isSafeInteger(value) &&
|
|
7
|
+
context.source !== undefined && /^-?\d+$/.test(context.source)) {
|
|
8
|
+
return BigInt(context.source);
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function stringifyJson(obj, space) {
|
|
18
|
+
return JSON.stringify(obj, (_key, value) => {
|
|
19
|
+
return typeof value === 'bigint' ? nativeJson.rawJSON(value.toString()) : value;
|
|
20
|
+
}, space);
|
|
21
|
+
}
|