@thienvu18/designable-shared 2.0.0 → 2.0.2
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/esm/animation.d.ts +8 -2
- package/esm/animation.js +29 -30
- package/esm/array.d.ts +163 -37
- package/esm/array.js +104 -87
- package/esm/clone.d.ts +4 -4
- package/esm/clone.js +79 -86
- package/esm/compose.d.ts +3 -1
- package/esm/compose.js +6 -6
- package/esm/coordinate.d.ts +120 -76
- package/esm/coordinate.js +480 -411
- package/esm/element.d.ts +11 -6
- package/esm/element.js +123 -125
- package/esm/event.d.ts +162 -75
- package/esm/event.js +197 -197
- package/esm/globalThisPolyfill.d.ts +1 -1
- package/esm/globalThisPolyfill.js +14 -17
- package/esm/index.d.ts +17 -17
- package/esm/index.js +17 -17
- package/esm/instanceof.d.ts +1 -1
- package/esm/instanceof.js +9 -10
- package/esm/keycode.d.ts +145 -145
- package/esm/keycode.js +149 -149
- package/esm/lru.d.ts +50 -47
- package/esm/lru.js +236 -245
- package/esm/observer.d.ts +7 -7
- package/esm/observer.js +37 -40
- package/esm/request-idle.d.ts +9 -6
- package/esm/request-idle.js +6 -6
- package/esm/scroller.d.ts +24 -8
- package/esm/scroller.js +78 -75
- package/esm/subscribable.d.ts +10 -10
- package/esm/subscribable.js +39 -40
- package/esm/types.d.ts +13 -13
- package/esm/types.js +19 -20
- package/esm/uid.d.ts +1 -1
- package/esm/uid.js +7 -7
- package/lib/animation.d.ts +8 -2
- package/lib/animation.js +34 -35
- package/lib/array.d.ts +163 -37
- package/lib/array.js +129 -101
- package/lib/clone.d.ts +4 -4
- package/lib/clone.js +84 -91
- package/lib/compose.d.ts +3 -1
- package/lib/compose.js +10 -10
- package/lib/coordinate.d.ts +120 -76
- package/lib/coordinate.js +538 -440
- package/lib/element.d.ts +11 -6
- package/lib/element.js +139 -133
- package/lib/event.d.ts +162 -75
- package/lib/event.js +206 -202
- package/lib/globalThisPolyfill.d.ts +1 -1
- package/lib/globalThisPolyfill.js +17 -20
- package/lib/index.d.ts +17 -17
- package/lib/index.js +49 -33
- package/lib/instanceof.d.ts +1 -1
- package/lib/instanceof.js +13 -14
- package/lib/keycode.d.ts +145 -145
- package/lib/keycode.js +153 -153
- package/lib/lru.d.ts +50 -47
- package/lib/lru.js +240 -249
- package/lib/observer.d.ts +7 -7
- package/lib/observer.js +41 -44
- package/lib/request-idle.d.ts +9 -6
- package/lib/request-idle.js +14 -11
- package/lib/scroller.d.ts +24 -8
- package/lib/scroller.js +89 -81
- package/lib/subscribable.d.ts +10 -10
- package/lib/subscribable.js +43 -44
- package/lib/types.d.ts +13 -13
- package/lib/types.js +40 -28
- package/lib/uid.d.ts +1 -1
- package/lib/uid.js +11 -11
- package/package.json +15 -15
package/lib/lru.d.ts
CHANGED
|
@@ -17,57 +17,60 @@
|
|
|
17
17
|
* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added
|
|
18
18
|
*/
|
|
19
19
|
export declare class LRUMap<K, V> {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
size: number
|
|
21
|
+
limit: number
|
|
22
|
+
oldest: any
|
|
23
|
+
newest: any
|
|
24
|
+
_keymap: Map<
|
|
25
|
+
K,
|
|
26
|
+
{
|
|
27
|
+
key: K
|
|
28
|
+
value: V
|
|
29
|
+
}
|
|
30
|
+
>
|
|
31
|
+
constructor(limit: number, entries?: any)
|
|
32
|
+
private _markEntryAsUsed
|
|
33
|
+
assign(entries: any): void
|
|
34
|
+
get(key: K): V
|
|
35
|
+
set(key: K, value: V): this
|
|
36
|
+
shift(): any[]
|
|
37
|
+
find(key: K): V
|
|
38
|
+
has(key: K): boolean
|
|
39
|
+
delete(key: any): V
|
|
40
|
+
clear(): void
|
|
41
|
+
keys(): KeyIterator
|
|
42
|
+
values(): ValueIterator
|
|
43
|
+
entries(): void
|
|
44
|
+
forEach(fun: (value: any, key: any, ctx: object) => void, thisObj: any): void
|
|
45
|
+
toJSON(): any[]
|
|
46
|
+
toString(): string
|
|
47
|
+
[Symbol.iterator](): EntryIterator
|
|
45
48
|
}
|
|
46
49
|
declare class EntryIterator {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
entry: any
|
|
51
|
+
constructor(oldestEntry: any)
|
|
52
|
+
[Symbol.iterator](): this
|
|
53
|
+
next(): {
|
|
54
|
+
done: boolean
|
|
55
|
+
value: any[]
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
declare class KeyIterator {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
entry: any
|
|
60
|
+
constructor(oldestEntry: any)
|
|
61
|
+
[Symbol.iterator](): this
|
|
62
|
+
next(): {
|
|
63
|
+
done: boolean
|
|
64
|
+
value: any
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
67
|
declare class ValueIterator {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
entry: any
|
|
69
|
+
constructor(oldestEntry: any)
|
|
70
|
+
[Symbol.iterator](): this
|
|
71
|
+
next(): {
|
|
72
|
+
done: boolean
|
|
73
|
+
value: any
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
|
-
export {}
|
|
76
|
+
export {}
|
package/lib/lru.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict'
|
|
2
2
|
/**
|
|
3
3
|
* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most
|
|
4
4
|
* recently used items while discarding least recently used items when its limit
|
|
@@ -18,280 +18,271 @@
|
|
|
18
18
|
* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added
|
|
19
19
|
*/
|
|
20
20
|
/* eslint-disable */
|
|
21
|
-
Object.defineProperty(exports,
|
|
22
|
-
exports.LRUMap = void 0
|
|
23
|
-
const NEWER = Symbol('newer')
|
|
24
|
-
const OLDER = Symbol('older')
|
|
21
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
22
|
+
exports.LRUMap = void 0
|
|
23
|
+
const NEWER = Symbol('newer')
|
|
24
|
+
const OLDER = Symbol('older')
|
|
25
25
|
function Entry(key, value) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
this.key = key
|
|
27
|
+
this.value = value
|
|
28
|
+
this[NEWER] = undefined
|
|
29
|
+
this[OLDER] = undefined
|
|
30
30
|
}
|
|
31
31
|
class LRUMap {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
this.size = 0;
|
|
39
|
-
this.limit = limit;
|
|
40
|
-
this.oldest = this.newest = undefined;
|
|
41
|
-
this._keymap = new Map();
|
|
42
|
-
if (entries) {
|
|
43
|
-
this.assign(entries);
|
|
44
|
-
if (limit < 1) {
|
|
45
|
-
this.limit = this.size;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
32
|
+
constructor(limit, entries) {
|
|
33
|
+
if (typeof limit !== 'number') {
|
|
34
|
+
// called as (entries)
|
|
35
|
+
entries = limit
|
|
36
|
+
limit = 0
|
|
48
37
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (entry[NEWER]) {
|
|
59
|
-
if (entry === this.oldest) {
|
|
60
|
-
this.oldest = entry[NEWER];
|
|
61
|
-
}
|
|
62
|
-
entry[NEWER][OLDER] = entry[OLDER]; // C <-- E.
|
|
63
|
-
}
|
|
64
|
-
if (entry[OLDER]) {
|
|
65
|
-
entry[OLDER][NEWER] = entry[NEWER]; // C. --> E
|
|
66
|
-
}
|
|
67
|
-
entry[NEWER] = undefined; // D --x
|
|
68
|
-
entry[OLDER] = this.newest; // D. --> E
|
|
69
|
-
if (this.newest) {
|
|
70
|
-
this.newest[NEWER] = entry; // E. <-- D
|
|
71
|
-
}
|
|
72
|
-
this.newest = entry;
|
|
38
|
+
this.size = 0
|
|
39
|
+
this.limit = limit
|
|
40
|
+
this.oldest = this.newest = undefined
|
|
41
|
+
this._keymap = new Map()
|
|
42
|
+
if (entries) {
|
|
43
|
+
this.assign(entries)
|
|
44
|
+
if (limit < 1) {
|
|
45
|
+
this.limit = this.size
|
|
46
|
+
}
|
|
73
47
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
for (let itv = it.next(); !itv.done; itv = it.next()) {
|
|
80
|
-
const e = new Entry(itv.value[0], itv.value[1]);
|
|
81
|
-
this._keymap.set(e.key, e);
|
|
82
|
-
if (!entry) {
|
|
83
|
-
this.oldest = e;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
entry[NEWER] = e;
|
|
87
|
-
e[OLDER] = entry;
|
|
88
|
-
}
|
|
89
|
-
entry = e;
|
|
90
|
-
if (limit-- === 0) {
|
|
91
|
-
throw new Error('overflow');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
this.newest = entry;
|
|
95
|
-
this.size = this._keymap.size;
|
|
48
|
+
}
|
|
49
|
+
_markEntryAsUsed(entry) {
|
|
50
|
+
if (entry === this.newest) {
|
|
51
|
+
// Already the most recenlty used entry, so no need to update the list
|
|
52
|
+
return
|
|
96
53
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
54
|
+
// HEAD--------------TAIL
|
|
55
|
+
// <.older .newer>
|
|
56
|
+
// <--- add direction --
|
|
57
|
+
// A B C <D> E
|
|
58
|
+
if (entry[NEWER]) {
|
|
59
|
+
if (entry === this.oldest) {
|
|
60
|
+
this.oldest = entry[NEWER]
|
|
61
|
+
}
|
|
62
|
+
entry[NEWER][OLDER] = entry[OLDER] // C <-- E.
|
|
106
63
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (entry) {
|
|
110
|
-
// update existing
|
|
111
|
-
entry.value = value;
|
|
112
|
-
this._markEntryAsUsed(entry);
|
|
113
|
-
return this;
|
|
114
|
-
}
|
|
115
|
-
// new entry
|
|
116
|
-
this._keymap.set(key, (entry = new Entry(key, value)));
|
|
117
|
-
if (this.newest) {
|
|
118
|
-
// link previous tail to the new tail (entry)
|
|
119
|
-
this.newest[NEWER] = entry;
|
|
120
|
-
entry[OLDER] = this.newest;
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
// we're first in -- yay
|
|
124
|
-
this.oldest = entry;
|
|
125
|
-
}
|
|
126
|
-
// add new entry to the end of the linked list -- it's now the freshest entry.
|
|
127
|
-
this.newest = entry;
|
|
128
|
-
++this.size;
|
|
129
|
-
if (this.size > this.limit) {
|
|
130
|
-
// we hit the limit -- remove the head
|
|
131
|
-
this.shift();
|
|
132
|
-
}
|
|
133
|
-
return this;
|
|
64
|
+
if (entry[OLDER]) {
|
|
65
|
+
entry[OLDER][NEWER] = entry[NEWER] // C. --> E
|
|
134
66
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (this.oldest[NEWER]) {
|
|
140
|
-
// advance the list
|
|
141
|
-
this.oldest = this.oldest[NEWER];
|
|
142
|
-
this.oldest[OLDER] = undefined;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
// the cache is exhausted
|
|
146
|
-
this.oldest = undefined;
|
|
147
|
-
this.newest = undefined;
|
|
148
|
-
}
|
|
149
|
-
// Remove last strong reference to <entry> and remove links from the purged
|
|
150
|
-
// entry being returned:
|
|
151
|
-
entry[NEWER] = entry[OLDER] = undefined;
|
|
152
|
-
this._keymap.delete(entry.key);
|
|
153
|
-
--this.size;
|
|
154
|
-
return [entry.key, entry.value];
|
|
155
|
-
}
|
|
67
|
+
entry[NEWER] = undefined // D --x
|
|
68
|
+
entry[OLDER] = this.newest // D. --> E
|
|
69
|
+
if (this.newest) {
|
|
70
|
+
this.newest[NEWER] = entry // E. <-- D
|
|
156
71
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
72
|
+
this.newest = entry
|
|
73
|
+
}
|
|
74
|
+
assign(entries) {
|
|
75
|
+
let entry
|
|
76
|
+
let limit = this.limit || Number.MAX_VALUE
|
|
77
|
+
this._keymap.clear()
|
|
78
|
+
const it = entries[Symbol.iterator]()
|
|
79
|
+
for (let itv = it.next(); !itv.done; itv = it.next()) {
|
|
80
|
+
const e = new Entry(itv.value[0], itv.value[1])
|
|
81
|
+
this._keymap.set(e.key, e)
|
|
82
|
+
if (!entry) {
|
|
83
|
+
this.oldest = e
|
|
84
|
+
} else {
|
|
85
|
+
entry[NEWER] = e
|
|
86
|
+
e[OLDER] = entry
|
|
87
|
+
}
|
|
88
|
+
entry = e
|
|
89
|
+
if (limit-- === 0) {
|
|
90
|
+
throw new Error('overflow')
|
|
91
|
+
}
|
|
160
92
|
}
|
|
161
|
-
|
|
162
|
-
|
|
93
|
+
this.newest = entry
|
|
94
|
+
this.size = this._keymap.size
|
|
95
|
+
}
|
|
96
|
+
get(key) {
|
|
97
|
+
// First, find our cache entry
|
|
98
|
+
const entry = this._keymap.get(key)
|
|
99
|
+
if (!entry) {
|
|
100
|
+
return
|
|
101
|
+
} // Not cached. Sorry.
|
|
102
|
+
// As <key> was found in the cache, register it as being requested recently
|
|
103
|
+
this._markEntryAsUsed(entry)
|
|
104
|
+
return entry.value
|
|
105
|
+
}
|
|
106
|
+
set(key, value) {
|
|
107
|
+
let entry = this._keymap.get(key)
|
|
108
|
+
if (entry) {
|
|
109
|
+
// update existing
|
|
110
|
+
entry.value = value
|
|
111
|
+
this._markEntryAsUsed(entry)
|
|
112
|
+
return this
|
|
163
113
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
entry[NEWER][OLDER] = entry[OLDER];
|
|
174
|
-
}
|
|
175
|
-
else if (entry[NEWER]) {
|
|
176
|
-
// remove the link to us
|
|
177
|
-
entry[NEWER][OLDER] = undefined;
|
|
178
|
-
// link the newer entry to head
|
|
179
|
-
this.oldest = entry[NEWER];
|
|
180
|
-
}
|
|
181
|
-
else if (entry[OLDER]) {
|
|
182
|
-
// remove the link to us
|
|
183
|
-
entry[OLDER][NEWER] = undefined;
|
|
184
|
-
// link the newer entry to head
|
|
185
|
-
this.newest = entry[OLDER];
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
// if(entry[OLDER] === undefined && entry.newer === undefined) {
|
|
189
|
-
this.oldest = this.newest = undefined;
|
|
190
|
-
}
|
|
191
|
-
this.size--;
|
|
192
|
-
return entry.value;
|
|
114
|
+
// new entry
|
|
115
|
+
this._keymap.set(key, (entry = new Entry(key, value)))
|
|
116
|
+
if (this.newest) {
|
|
117
|
+
// link previous tail to the new tail (entry)
|
|
118
|
+
this.newest[NEWER] = entry
|
|
119
|
+
entry[OLDER] = this.newest
|
|
120
|
+
} else {
|
|
121
|
+
// we're first in -- yay
|
|
122
|
+
this.oldest = entry
|
|
193
123
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
124
|
+
// add new entry to the end of the linked list -- it's now the freshest entry.
|
|
125
|
+
this.newest = entry
|
|
126
|
+
++this.size
|
|
127
|
+
if (this.size > this.limit) {
|
|
128
|
+
// we hit the limit -- remove the head
|
|
129
|
+
this.shift()
|
|
199
130
|
}
|
|
200
|
-
|
|
201
|
-
|
|
131
|
+
return this
|
|
132
|
+
}
|
|
133
|
+
shift() {
|
|
134
|
+
// todo: handle special case when limit == 1
|
|
135
|
+
const entry = this.oldest
|
|
136
|
+
if (entry) {
|
|
137
|
+
if (this.oldest[NEWER]) {
|
|
138
|
+
// advance the list
|
|
139
|
+
this.oldest = this.oldest[NEWER]
|
|
140
|
+
this.oldest[OLDER] = undefined
|
|
141
|
+
} else {
|
|
142
|
+
// the cache is exhausted
|
|
143
|
+
this.oldest = undefined
|
|
144
|
+
this.newest = undefined
|
|
145
|
+
}
|
|
146
|
+
// Remove last strong reference to <entry> and remove links from the purged
|
|
147
|
+
// entry being returned:
|
|
148
|
+
entry[NEWER] = entry[OLDER] = undefined
|
|
149
|
+
this._keymap.delete(entry.key)
|
|
150
|
+
--this.size
|
|
151
|
+
return [entry.key, entry.value]
|
|
202
152
|
}
|
|
203
|
-
|
|
204
|
-
|
|
153
|
+
}
|
|
154
|
+
find(key) {
|
|
155
|
+
const e = this._keymap.get(key)
|
|
156
|
+
return e ? e.value : undefined
|
|
157
|
+
}
|
|
158
|
+
has(key) {
|
|
159
|
+
return this._keymap.has(key)
|
|
160
|
+
}
|
|
161
|
+
delete(key) {
|
|
162
|
+
const entry = this._keymap.get(key)
|
|
163
|
+
if (!entry) {
|
|
164
|
+
return
|
|
205
165
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
166
|
+
this._keymap.delete(entry.key)
|
|
167
|
+
if (entry[NEWER] && entry[OLDER]) {
|
|
168
|
+
// relink the older entry with the newer entry
|
|
169
|
+
entry[OLDER][NEWER] = entry[NEWER]
|
|
170
|
+
entry[NEWER][OLDER] = entry[OLDER]
|
|
171
|
+
} else if (entry[NEWER]) {
|
|
172
|
+
// remove the link to us
|
|
173
|
+
entry[NEWER][OLDER] = undefined
|
|
174
|
+
// link the newer entry to head
|
|
175
|
+
this.oldest = entry[NEWER]
|
|
176
|
+
} else if (entry[OLDER]) {
|
|
177
|
+
// remove the link to us
|
|
178
|
+
entry[OLDER][NEWER] = undefined
|
|
179
|
+
// link the newer entry to head
|
|
180
|
+
this.newest = entry[OLDER]
|
|
181
|
+
} else {
|
|
182
|
+
// if(entry[OLDER] === undefined && entry.newer === undefined) {
|
|
183
|
+
this.oldest = this.newest = undefined
|
|
216
184
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
185
|
+
this.size--
|
|
186
|
+
return entry.value
|
|
187
|
+
}
|
|
188
|
+
clear() {
|
|
189
|
+
// Not clearing links should be safe, as we don't expose live links to user
|
|
190
|
+
this.oldest = this.newest = undefined
|
|
191
|
+
this.size = 0
|
|
192
|
+
this._keymap.clear()
|
|
193
|
+
}
|
|
194
|
+
keys() {
|
|
195
|
+
return new KeyIterator(this.oldest)
|
|
196
|
+
}
|
|
197
|
+
values() {
|
|
198
|
+
return new ValueIterator(this.oldest)
|
|
199
|
+
}
|
|
200
|
+
entries() {}
|
|
201
|
+
forEach(fun, thisObj) {
|
|
202
|
+
if (typeof thisObj !== 'object') {
|
|
203
|
+
thisObj = this
|
|
226
204
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
s += String(entry.key) + ':' + entry.value;
|
|
232
|
-
entry = entry[NEWER];
|
|
233
|
-
if (entry) {
|
|
234
|
-
s += ' < ';
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return s;
|
|
205
|
+
let entry = this.oldest
|
|
206
|
+
while (entry) {
|
|
207
|
+
fun.call(thisObj, entry.value, entry.key, this)
|
|
208
|
+
entry = entry[NEWER]
|
|
238
209
|
}
|
|
239
|
-
|
|
240
|
-
|
|
210
|
+
}
|
|
211
|
+
toJSON() {
|
|
212
|
+
const s = new Array(this.size)
|
|
213
|
+
let i = 0
|
|
214
|
+
let entry = this.oldest
|
|
215
|
+
while (entry) {
|
|
216
|
+
s[i++] = { key: entry.key, value: entry.value }
|
|
217
|
+
entry = entry[NEWER]
|
|
241
218
|
}
|
|
219
|
+
return s
|
|
220
|
+
}
|
|
221
|
+
toString() {
|
|
222
|
+
let s = ''
|
|
223
|
+
let entry = this.oldest
|
|
224
|
+
while (entry) {
|
|
225
|
+
s += String(entry.key) + ':' + entry.value
|
|
226
|
+
entry = entry[NEWER]
|
|
227
|
+
if (entry) {
|
|
228
|
+
s += ' < '
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return s
|
|
232
|
+
}
|
|
233
|
+
[Symbol.iterator]() {
|
|
234
|
+
return new EntryIterator(this.oldest)
|
|
235
|
+
}
|
|
242
236
|
}
|
|
243
|
-
exports.LRUMap = LRUMap
|
|
237
|
+
exports.LRUMap = LRUMap
|
|
244
238
|
class EntryIterator {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return { done: true, value: undefined };
|
|
259
|
-
}
|
|
239
|
+
constructor(oldestEntry) {
|
|
240
|
+
this.entry = oldestEntry
|
|
241
|
+
}
|
|
242
|
+
[Symbol.iterator]() {
|
|
243
|
+
return this
|
|
244
|
+
}
|
|
245
|
+
next() {
|
|
246
|
+
const ent = this.entry
|
|
247
|
+
if (ent) {
|
|
248
|
+
this.entry = ent[NEWER]
|
|
249
|
+
return { done: false, value: [ent.key, ent.value] }
|
|
250
|
+
} else {
|
|
251
|
+
return { done: true, value: undefined }
|
|
260
252
|
}
|
|
253
|
+
}
|
|
261
254
|
}
|
|
262
255
|
class KeyIterator {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return { done: true, value: undefined };
|
|
277
|
-
}
|
|
256
|
+
constructor(oldestEntry) {
|
|
257
|
+
this.entry = oldestEntry
|
|
258
|
+
}
|
|
259
|
+
[Symbol.iterator]() {
|
|
260
|
+
return this
|
|
261
|
+
}
|
|
262
|
+
next() {
|
|
263
|
+
const ent = this.entry
|
|
264
|
+
if (ent) {
|
|
265
|
+
this.entry = ent[NEWER]
|
|
266
|
+
return { done: false, value: ent.key }
|
|
267
|
+
} else {
|
|
268
|
+
return { done: true, value: undefined }
|
|
278
269
|
}
|
|
270
|
+
}
|
|
279
271
|
}
|
|
280
272
|
class ValueIterator {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return { done: true, value: undefined };
|
|
295
|
-
}
|
|
273
|
+
constructor(oldestEntry) {
|
|
274
|
+
this.entry = oldestEntry
|
|
275
|
+
}
|
|
276
|
+
[Symbol.iterator]() {
|
|
277
|
+
return this
|
|
278
|
+
}
|
|
279
|
+
next() {
|
|
280
|
+
const ent = this.entry
|
|
281
|
+
if (ent) {
|
|
282
|
+
this.entry = ent[NEWER]
|
|
283
|
+
return { done: false, value: ent.value }
|
|
284
|
+
} else {
|
|
285
|
+
return { done: true, value: undefined }
|
|
296
286
|
}
|
|
287
|
+
}
|
|
297
288
|
}
|
package/lib/observer.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare class LayoutObserver {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
private resizeObserver?
|
|
3
|
+
private performanceObserver?
|
|
4
|
+
private mutationObserver?
|
|
5
|
+
private connected
|
|
6
|
+
constructor(observer?: () => void)
|
|
7
|
+
observe: (target: HTMLElement | Element) => void
|
|
8
|
+
disconnect: () => void
|
|
9
9
|
}
|