solarite 0.5.2 → 0.7.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/dist/Solarite-debug.js +4847 -3878
- package/dist/Solarite.js +4583 -3626
- package/dist/Solarite.min.js +2 -4
- package/package.json +19 -6
- package/readme.md +58 -11
- package/src/Globals.js +54 -72
- package/src/HtmlParser.js +90 -90
- package/src/MultiValueMap.js +57 -105
- package/src/NodeGroup.js +624 -470
- package/src/Path.js +224 -211
- package/src/PathToAttribValue.js +401 -261
- package/src/PathToAttribs.js +113 -80
- package/src/PathToComment.js +7 -7
- package/src/PathToComponent.js +183 -188
- package/src/PathToEvent.js +76 -64
- package/src/PathToKey.js +19 -0
- package/src/PathToNodes.js +1053 -566
- package/src/RootNodeGroup.js +120 -8
- package/src/Shell.js +570 -348
- package/src/Solarite.d.ts +134 -113
- package/src/Solarite.js +243 -286
- package/src/Template.js +195 -274
- package/src/Util.js +353 -351
- package/src/assert.js +10 -10
- package/src/assignAttributes.js +63 -0
- package/src/delve.js +55 -43
- package/src/h.js +220 -138
- package/src/jsx-dev-runtime.d.ts +1 -0
- package/src/jsx-dev-runtime.js +5 -0
- package/src/jsx-runtime.d.ts +21 -0
- package/src/jsx-runtime.js +84 -0
- package/src/jsx.js +194 -0
- package/src/toEl.js +77 -82
- package/dist/udomdiff-license.txt +0 -18
- package/src/getArg.js +0 -137
- package/src/hash.js +0 -89
- package/src/udomdiff.js +0 -176
- package/src/unused/FastLookupArray.js +0 -54
- package/src/unused/Hashes.js +0 -339
- package/src/unused/InUse.test.js +0 -92
- package/src/unused/InUseMap.js +0 -98
- package/src/unused/LinkedList.js +0 -117
- package/src/unused/LinkedList.test.js +0 -115
- package/src/unused/Misc.js +0 -13
- package/src/unused/Perf.js +0 -47
- package/src/unused/TrackedArray.js +0 -54
- package/src/unused/WeakArray.js +0 -33
- package/src/watch.js +0 -543
package/src/MultiValueMap.js
CHANGED
|
@@ -1,105 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
* @param key {string}
|
|
26
|
-
* @
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Remove any one value from a key, and return it.
|
|
63
|
-
* @param key {string}
|
|
64
|
-
* @returns {*|undefined} The deleted item. */
|
|
65
|
-
deleteAny(key) {
|
|
66
|
-
let data = this.data;
|
|
67
|
-
let result;
|
|
68
|
-
let set = data[key];
|
|
69
|
-
if (!set) // slower than pre-check.
|
|
70
|
-
return undefined;
|
|
71
|
-
|
|
72
|
-
[result] = set; // Get the first value from the set.
|
|
73
|
-
set.delete(result);
|
|
74
|
-
|
|
75
|
-
if (set.size === 0)
|
|
76
|
-
delete data[key];
|
|
77
|
-
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
deleteSpecific(key, val) {
|
|
82
|
-
let data = this.data;
|
|
83
|
-
let result;
|
|
84
|
-
let set = data[key];
|
|
85
|
-
if (!set)
|
|
86
|
-
return undefined;
|
|
87
|
-
|
|
88
|
-
set.delete(val);
|
|
89
|
-
result = val;
|
|
90
|
-
|
|
91
|
-
if (set.size === 0)
|
|
92
|
-
delete data[key];
|
|
93
|
-
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
hasValue(val) {
|
|
98
|
-
let data = this.data;
|
|
99
|
-
let names = [];
|
|
100
|
-
for (let name in data)
|
|
101
|
-
if (data[name].has(val)) // TODO: iterate twice to pre-size array?
|
|
102
|
-
names.push(name)
|
|
103
|
-
return names;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Maps a string key to multiple values.
|
|
3
|
+
* Values are stored in arrays because pushing them is much faster than Set operations,
|
|
4
|
+
* and deleteAny() needs no iterator allocation.
|
|
5
|
+
* deleteAny() returns values first-in-first-out by advancing a head index (array.head)
|
|
6
|
+
* instead of calling shift(), which would be O(n). */
|
|
7
|
+
export default class MultiValueMap {
|
|
8
|
+
|
|
9
|
+
/** @type {Record<string, Array>} */
|
|
10
|
+
data = {};
|
|
11
|
+
|
|
12
|
+
// Add a new value for a key
|
|
13
|
+
add(key, value) {
|
|
14
|
+
let data = this.data;
|
|
15
|
+
let array = data[key]
|
|
16
|
+
if (!array)
|
|
17
|
+
data[key] = [value];
|
|
18
|
+
else
|
|
19
|
+
array.push(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Add a new value for a key, unless the key already holds max values.
|
|
24
|
+
* Used to bound pooled NodeGroup memory.
|
|
25
|
+
* @param key {string}
|
|
26
|
+
* @param value
|
|
27
|
+
* @param max {int} */
|
|
28
|
+
addCapped(key, value, max) {
|
|
29
|
+
let data = this.data;
|
|
30
|
+
let array = data[key]
|
|
31
|
+
if (!array)
|
|
32
|
+
data[key] = [value];
|
|
33
|
+
else if (array.length - (array.head || 0) < max)
|
|
34
|
+
array.push(value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Remove the oldest value from a key, and return it.
|
|
39
|
+
* @param key {string}
|
|
40
|
+
* @returns {*|undefined} The deleted item. */
|
|
41
|
+
deleteAny(key) {
|
|
42
|
+
let data = this.data;
|
|
43
|
+
let array = data[key];
|
|
44
|
+
if (!array) // slower than pre-check.
|
|
45
|
+
return undefined;
|
|
46
|
+
|
|
47
|
+
let head = array.head || 0;
|
|
48
|
+
let result = array[head];
|
|
49
|
+
head++;
|
|
50
|
+
if (head >= array.length)
|
|
51
|
+
delete data[key];
|
|
52
|
+
else
|
|
53
|
+
array.head = head;
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
}
|