toon-parser 1.0.0 → 1.1.1
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/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/index.cjs +874 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +868 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -12
- package/index.js +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
2
|
+
export interface SecurityOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Maximum nesting depth (objects + arrays). Defaults to 64.
|
|
5
|
+
*/
|
|
6
|
+
maxDepth?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Maximum allowed array length. Defaults to 50_000.
|
|
9
|
+
*/
|
|
10
|
+
maxArrayLength?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum total nodes (object fields + array items) processed.
|
|
13
|
+
* Defaults to 250_000 to limit resource exhaustion.
|
|
14
|
+
*/
|
|
15
|
+
maxTotalNodes?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Keys that are rejected to avoid prototype pollution.
|
|
18
|
+
* Defaults to ["__proto__", "constructor", "prototype"].
|
|
19
|
+
*/
|
|
20
|
+
disallowedKeys?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface JsonToToonOptions extends SecurityOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Number of spaces per indentation level. Defaults to 2.
|
|
25
|
+
*/
|
|
26
|
+
indent?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Delimiter to use for inline arrays and tabular rows.
|
|
29
|
+
* Defaults to comma.
|
|
30
|
+
*/
|
|
31
|
+
delimiter?: ',' | '|' | '\t';
|
|
32
|
+
/**
|
|
33
|
+
* When true, object keys are sorted alphabetically to keep output deterministic.
|
|
34
|
+
* Defaults to false (preserve encounter order).
|
|
35
|
+
*/
|
|
36
|
+
sortKeys?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface ToonToJsonOptions extends SecurityOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Enforce declared array lengths, field counts, and indentation consistency.
|
|
41
|
+
* Defaults to true.
|
|
42
|
+
*/
|
|
43
|
+
strict?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare class ToonError extends Error {
|
|
46
|
+
readonly line?: number;
|
|
47
|
+
constructor(message: string, line?: number);
|
|
48
|
+
}
|
|
49
|
+
export declare function jsonToToon(value: unknown, options?: JsonToToonOptions): string;
|
|
50
|
+
export declare function toonToJson(text: string, options?: ToonToJsonOptions): unknown;
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAiDD,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAK3C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAuIlF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CA6TjF"}
|