@tslite/parser 1.9.0 → 1.12.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.
- package/LICENSE +55 -0
- package/NOTICE +14 -0
- package/dist/_namespaces/ts.d.ts +18 -0
- package/dist/_namespaces/ts.js +21 -0
- package/dist/_namespaces/ts.performance.d.ts +1 -0
- package/dist/_namespaces/ts.performance.js +2 -0
- package/dist/core.d.ts +450 -0
- package/dist/core.js +1394 -0
- package/dist/corePublic.d.ts +62 -0
- package/dist/corePublic.js +31 -0
- package/dist/debug.d.ts +74 -0
- package/dist/debug.js +326 -0
- package/dist/diagnosticInformationMap.generated.d.ts +1435 -0
- package/dist/diagnosticInformationMap.generated.js +1441 -0
- package/dist/factory.d.ts +78 -0
- package/dist/factory.js +622 -0
- package/dist/factoryPublic.d.ts +314 -0
- package/dist/factoryPublic.js +1796 -0
- package/dist/index.d.ts +1 -249
- package/dist/index.js +4 -6
- package/dist/parser.d.ts +59 -0
- package/dist/parser.js +5075 -0
- package/dist/path.d.ts +312 -0
- package/dist/path.js +475 -0
- package/dist/perfLogger.d.ts +4 -0
- package/dist/perfLogger.js +38 -0
- package/dist/performance.d.ts +20 -0
- package/dist/performance.js +49 -0
- package/dist/performanceTimestamp.d.ts +2 -0
- package/dist/performanceTimestamp.js +2 -0
- package/dist/scanner.d.ts +80 -0
- package/dist/scanner.js +1984 -0
- package/dist/shims/mapShim.d.ts +23 -0
- package/dist/shims/mapShim.js +156 -0
- package/dist/types.d.ts +2626 -0
- package/dist/types.js +1074 -0
- package/dist/utilities.d.ts +473 -0
- package/dist/utilities.js +2632 -0
- package/dist/utilitiesPublic.d.ts +274 -0
- package/dist/utilitiesPublic.js +1049 -0
- package/dist/visitor.d.ts +15 -0
- package/dist/visitor.js +64 -0
- package/dist/visitorPublic.d.ts +82 -0
- package/dist/visitorPublic.js +352 -0
- package/package.json +14 -42
- package/dist/index.cjs +0 -6
- package/dist/index.d.cts +0 -249
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface IteratorShim<T> {
|
|
2
|
+
next(): {
|
|
3
|
+
value: T;
|
|
4
|
+
done?: false;
|
|
5
|
+
} | {
|
|
6
|
+
value: never;
|
|
7
|
+
done: true;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
interface MapShim<T> {
|
|
11
|
+
readonly size: number;
|
|
12
|
+
get(key: string): T | undefined;
|
|
13
|
+
set(key: string, value: T): this;
|
|
14
|
+
has(key: string): boolean;
|
|
15
|
+
delete(key: string): boolean;
|
|
16
|
+
clear(): void;
|
|
17
|
+
keys(): IteratorShim<string>;
|
|
18
|
+
values(): IteratorShim<T>;
|
|
19
|
+
entries(): IteratorShim<[string, T]>;
|
|
20
|
+
forEach(action: (value: T, key: string) => void): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createMapShim(): new <T>() => MapShim<T>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export function createMapShim() {
|
|
2
|
+
/** Create a MapLike with good performance. */
|
|
3
|
+
function createDictionaryObject() {
|
|
4
|
+
const map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null
|
|
5
|
+
// Using 'delete' on an object causes V8 to put the object in dictionary mode.
|
|
6
|
+
// This disables creation of hidden classes, which are expensive when an object is
|
|
7
|
+
// constantly changing shape.
|
|
8
|
+
map.__ = undefined;
|
|
9
|
+
delete map.__;
|
|
10
|
+
return map;
|
|
11
|
+
}
|
|
12
|
+
class MapIterator {
|
|
13
|
+
currentEntry;
|
|
14
|
+
selector;
|
|
15
|
+
constructor(currentEntry, selector) {
|
|
16
|
+
this.currentEntry = currentEntry;
|
|
17
|
+
this.selector = selector;
|
|
18
|
+
}
|
|
19
|
+
next() {
|
|
20
|
+
// Navigate to the next entry.
|
|
21
|
+
while (this.currentEntry) {
|
|
22
|
+
const skipNext = !!this.currentEntry.skipNext;
|
|
23
|
+
this.currentEntry = this.currentEntry.nextEntry;
|
|
24
|
+
if (!skipNext) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (this.currentEntry) {
|
|
29
|
+
return { value: this.selector(this.currentEntry.key, this.currentEntry.value), done: false };
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return { value: undefined, done: true };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return class {
|
|
37
|
+
data = createDictionaryObject();
|
|
38
|
+
size = 0;
|
|
39
|
+
// Linked list references for iterators.
|
|
40
|
+
// See https://github.com/Microsoft/TypeScript/pull/27292
|
|
41
|
+
// for more information.
|
|
42
|
+
/**
|
|
43
|
+
* The first entry in the linked list.
|
|
44
|
+
* Note that this is only a stub that serves as starting point
|
|
45
|
+
* for iterators and doesn't contain a key and a value.
|
|
46
|
+
*/
|
|
47
|
+
firstEntry;
|
|
48
|
+
lastEntry;
|
|
49
|
+
constructor() {
|
|
50
|
+
// Create a first (stub) map entry that will not contain a key
|
|
51
|
+
// and value but serves as starting point for iterators.
|
|
52
|
+
this.firstEntry = {};
|
|
53
|
+
// When the map is empty, the last entry is the same as the
|
|
54
|
+
// first one.
|
|
55
|
+
this.lastEntry = this.firstEntry;
|
|
56
|
+
}
|
|
57
|
+
get(key) {
|
|
58
|
+
const entry = this.data[key];
|
|
59
|
+
return entry && entry.value;
|
|
60
|
+
}
|
|
61
|
+
set(key, value) {
|
|
62
|
+
if (!this.has(key)) {
|
|
63
|
+
this.size++;
|
|
64
|
+
// Create a new entry that will be appended at the
|
|
65
|
+
// end of the linked list.
|
|
66
|
+
const newEntry = {
|
|
67
|
+
key,
|
|
68
|
+
value
|
|
69
|
+
};
|
|
70
|
+
this.data[key] = newEntry;
|
|
71
|
+
// Adjust the references.
|
|
72
|
+
const previousLastEntry = this.lastEntry;
|
|
73
|
+
previousLastEntry.nextEntry = newEntry;
|
|
74
|
+
newEntry.previousEntry = previousLastEntry;
|
|
75
|
+
this.lastEntry = newEntry;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.data[key].value = value;
|
|
79
|
+
}
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
has(key) {
|
|
83
|
+
// eslint-disable-next-line no-in-operator
|
|
84
|
+
return key in this.data;
|
|
85
|
+
}
|
|
86
|
+
delete(key) {
|
|
87
|
+
if (this.has(key)) {
|
|
88
|
+
this.size--;
|
|
89
|
+
const entry = this.data[key];
|
|
90
|
+
delete this.data[key];
|
|
91
|
+
// Adjust the linked list references of the neighbor entries.
|
|
92
|
+
const previousEntry = entry.previousEntry;
|
|
93
|
+
previousEntry.nextEntry = entry.nextEntry;
|
|
94
|
+
if (entry.nextEntry) {
|
|
95
|
+
entry.nextEntry.previousEntry = previousEntry;
|
|
96
|
+
}
|
|
97
|
+
// When the deleted entry was the last one, we need to
|
|
98
|
+
// adjust the lastEntry reference.
|
|
99
|
+
if (this.lastEntry === entry) {
|
|
100
|
+
this.lastEntry = previousEntry;
|
|
101
|
+
}
|
|
102
|
+
// Adjust the forward reference of the deleted entry
|
|
103
|
+
// in case an iterator still references it. This allows us
|
|
104
|
+
// to throw away the entry, but when an active iterator
|
|
105
|
+
// (which points to the current entry) continues, it will
|
|
106
|
+
// navigate to the entry that originally came before the
|
|
107
|
+
// current one and skip it.
|
|
108
|
+
entry.previousEntry = undefined;
|
|
109
|
+
entry.nextEntry = previousEntry;
|
|
110
|
+
entry.skipNext = true;
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
clear() {
|
|
116
|
+
this.data = createDictionaryObject();
|
|
117
|
+
this.size = 0;
|
|
118
|
+
// Reset the linked list. Note that we must adjust the forward
|
|
119
|
+
// references of the deleted entries to ensure iterators stuck
|
|
120
|
+
// in the middle of the list don't continue with deleted entries,
|
|
121
|
+
// but can continue with new entries added after the clear()
|
|
122
|
+
// operation.
|
|
123
|
+
const firstEntry = this.firstEntry;
|
|
124
|
+
let currentEntry = firstEntry.nextEntry;
|
|
125
|
+
while (currentEntry) {
|
|
126
|
+
const nextEntry = currentEntry.nextEntry;
|
|
127
|
+
currentEntry.previousEntry = undefined;
|
|
128
|
+
currentEntry.nextEntry = firstEntry;
|
|
129
|
+
currentEntry.skipNext = true;
|
|
130
|
+
currentEntry = nextEntry;
|
|
131
|
+
}
|
|
132
|
+
firstEntry.nextEntry = undefined;
|
|
133
|
+
this.lastEntry = firstEntry;
|
|
134
|
+
}
|
|
135
|
+
keys() {
|
|
136
|
+
return new MapIterator(this.firstEntry, key => key);
|
|
137
|
+
}
|
|
138
|
+
values() {
|
|
139
|
+
return new MapIterator(this.firstEntry, (_key, value) => value);
|
|
140
|
+
}
|
|
141
|
+
entries() {
|
|
142
|
+
return new MapIterator(this.firstEntry, (key, value) => [key, value]);
|
|
143
|
+
}
|
|
144
|
+
forEach(action) {
|
|
145
|
+
const iterator = this.entries();
|
|
146
|
+
while (true) {
|
|
147
|
+
const iterResult = iterator.next();
|
|
148
|
+
if (iterResult.done) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
const [key, value] = iterResult.value;
|
|
152
|
+
action(value, key);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|