@malloydata/malloy 0.0.117-dev240110184814 → 0.0.117-dev240110202509
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/tags.d.ts +1 -1
- package/dist/tags.js +17 -7
- package/package.json +1 -1
package/dist/tags.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare class Tag implements TagInterface {
|
|
|
42
42
|
static ids: Map<Tag, number>;
|
|
43
43
|
static nextTagId: number;
|
|
44
44
|
static id(t: Tag): number;
|
|
45
|
-
peek(): string;
|
|
45
|
+
peek(indent?: number): string;
|
|
46
46
|
/**
|
|
47
47
|
* Parse a line of Malloy tag language into a Tag which can be queried
|
|
48
48
|
* @param source -- The source line to be parsed. If the string starts with #, then it skips
|
package/dist/tags.js
CHANGED
|
@@ -60,22 +60,32 @@ class Tag {
|
|
|
60
60
|
}
|
|
61
61
|
return thisTagId;
|
|
62
62
|
}
|
|
63
|
-
peek() {
|
|
63
|
+
peek(indent = 0) {
|
|
64
|
+
const spaces = ' '.repeat(indent);
|
|
64
65
|
let str = `#${Tag.id(this)}`;
|
|
66
|
+
if (this.properties === undefined &&
|
|
67
|
+
this.eq &&
|
|
68
|
+
typeof this.eq === 'string') {
|
|
69
|
+
return str + `=${this.eq}`;
|
|
70
|
+
}
|
|
71
|
+
str += ' {';
|
|
65
72
|
if (this.eq) {
|
|
66
73
|
if (typeof this.eq === 'string') {
|
|
67
|
-
str +=
|
|
74
|
+
str += `\n${spaces} =: ${this.eq}`;
|
|
68
75
|
}
|
|
69
76
|
else {
|
|
70
|
-
str +=
|
|
77
|
+
str += `\n${spaces} =: [\n${spaces} ${this.eq
|
|
78
|
+
.map(el => new Tag(el).peek(indent + 4))
|
|
79
|
+
.join(`\n${spaces} `)}\n${spaces} ]`;
|
|
71
80
|
}
|
|
72
81
|
}
|
|
73
82
|
if (this.properties) {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
|
|
83
|
+
for (const k in this.properties) {
|
|
84
|
+
const val = new Tag(this.properties[k]);
|
|
85
|
+
str += `\n${spaces} ${k}: ${val.peek(indent + 2)}`;
|
|
86
|
+
}
|
|
78
87
|
}
|
|
88
|
+
str += `\n${spaces}}`;
|
|
79
89
|
return str;
|
|
80
90
|
}
|
|
81
91
|
/**
|