rantjs 1.0.10 → 2.0.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.
@@ -0,0 +1,72 @@
1
+ interface Entry {
2
+ forms: string[];
3
+ classes: string[];
4
+ }
5
+ interface Table {
6
+ name: string;
7
+ subs: string[];
8
+ entries: Entry[];
9
+ }
10
+ interface Dictionary {
11
+ tables: Record<string, Table>;
12
+ }
13
+
14
+ declare const enUS: Dictionary;
15
+
16
+ interface RantOptions {
17
+ seed?: number | string;
18
+ dictionary?: Dictionary;
19
+ nsfw?: boolean;
20
+ }
21
+ interface RantInstance {
22
+ run(pattern: string, options?: RantOptions): string;
23
+ }
24
+ declare function createRant(options?: RantOptions): RantInstance;
25
+ declare function rant(pattern: string, second?: RantOptions | Dictionary | unknown): string;
26
+
27
+ type Node = TextNode | QueryNode | TagNode | BlockNode | EscapeNode;
28
+ interface TextNode {
29
+ type: "text";
30
+ value: string;
31
+ }
32
+ interface QueryNode {
33
+ type: "query";
34
+ table: string;
35
+ args: string[];
36
+ carrier?: string;
37
+ raw: string;
38
+ }
39
+ interface TagNode {
40
+ type: "tag";
41
+ name: string;
42
+ arg: string;
43
+ }
44
+ interface BlockNode {
45
+ type: "block";
46
+ alternatives: Node[][];
47
+ }
48
+ interface EscapeNode {
49
+ type: "escape";
50
+ code: string;
51
+ }
52
+
53
+ declare function parse(input: string): Node[];
54
+
55
+ interface CompileOptions {
56
+ aliases?: Record<string, string>;
57
+ }
58
+ declare function compileDic(source: string, fallbackName?: string): Table;
59
+ declare function compileDictionaries(files: {
60
+ name: string;
61
+ source: string;
62
+ }[], options?: CompileOptions): Dictionary;
63
+
64
+ interface Rng {
65
+ next(): number;
66
+ int(max: number): number;
67
+ pick<T>(items: readonly T[]): T;
68
+ }
69
+ /** Mulberry32 — small, fast, deterministic 32-bit PRNG. */
70
+ declare function createRng(seed?: number | string): Rng;
71
+
72
+ export { type Dictionary, type Entry, type RantInstance, type RantOptions, type Table, compileDic, compileDictionaries, createRant, createRng, enUS, parse, rant };
@@ -0,0 +1,72 @@
1
+ interface Entry {
2
+ forms: string[];
3
+ classes: string[];
4
+ }
5
+ interface Table {
6
+ name: string;
7
+ subs: string[];
8
+ entries: Entry[];
9
+ }
10
+ interface Dictionary {
11
+ tables: Record<string, Table>;
12
+ }
13
+
14
+ declare const enUS: Dictionary;
15
+
16
+ interface RantOptions {
17
+ seed?: number | string;
18
+ dictionary?: Dictionary;
19
+ nsfw?: boolean;
20
+ }
21
+ interface RantInstance {
22
+ run(pattern: string, options?: RantOptions): string;
23
+ }
24
+ declare function createRant(options?: RantOptions): RantInstance;
25
+ declare function rant(pattern: string, second?: RantOptions | Dictionary | unknown): string;
26
+
27
+ type Node = TextNode | QueryNode | TagNode | BlockNode | EscapeNode;
28
+ interface TextNode {
29
+ type: "text";
30
+ value: string;
31
+ }
32
+ interface QueryNode {
33
+ type: "query";
34
+ table: string;
35
+ args: string[];
36
+ carrier?: string;
37
+ raw: string;
38
+ }
39
+ interface TagNode {
40
+ type: "tag";
41
+ name: string;
42
+ arg: string;
43
+ }
44
+ interface BlockNode {
45
+ type: "block";
46
+ alternatives: Node[][];
47
+ }
48
+ interface EscapeNode {
49
+ type: "escape";
50
+ code: string;
51
+ }
52
+
53
+ declare function parse(input: string): Node[];
54
+
55
+ interface CompileOptions {
56
+ aliases?: Record<string, string>;
57
+ }
58
+ declare function compileDic(source: string, fallbackName?: string): Table;
59
+ declare function compileDictionaries(files: {
60
+ name: string;
61
+ source: string;
62
+ }[], options?: CompileOptions): Dictionary;
63
+
64
+ interface Rng {
65
+ next(): number;
66
+ int(max: number): number;
67
+ pick<T>(items: readonly T[]): T;
68
+ }
69
+ /** Mulberry32 — small, fast, deterministic 32-bit PRNG. */
70
+ declare function createRng(seed?: number | string): Rng;
71
+
72
+ export { type Dictionary, type Entry, type RantInstance, type RantOptions, type Table, compileDic, compileDictionaries, createRant, createRng, enUS, parse, rant };