@primer/behaviors 0.0.0-20251215034201 → 0.0.0-20251215124648
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.
|
@@ -1,55 +1,52 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib = require('tslib');
|
|
4
|
-
|
|
5
|
-
var _IndexedSet_items, _IndexedSet_itemSet;
|
|
6
3
|
class IndexedSet {
|
|
7
4
|
constructor() {
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
this._items = [];
|
|
6
|
+
this._itemSet = new Set();
|
|
10
7
|
}
|
|
11
8
|
insertAt(index, ...elements) {
|
|
12
|
-
const newElements = elements.filter(e => !
|
|
9
|
+
const newElements = elements.filter(e => !this._itemSet.has(e));
|
|
13
10
|
if (newElements.length === 0)
|
|
14
11
|
return;
|
|
15
|
-
|
|
12
|
+
this._items.splice(index, 0, ...newElements);
|
|
16
13
|
for (const element of newElements) {
|
|
17
|
-
|
|
14
|
+
this._itemSet.add(element);
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
delete(element) {
|
|
21
|
-
if (!
|
|
18
|
+
if (!this._itemSet.has(element))
|
|
22
19
|
return false;
|
|
23
|
-
const index =
|
|
20
|
+
const index = this._items.indexOf(element);
|
|
24
21
|
if (index >= 0) {
|
|
25
|
-
|
|
22
|
+
this._items.splice(index, 1);
|
|
26
23
|
}
|
|
27
|
-
|
|
24
|
+
this._itemSet.delete(element);
|
|
28
25
|
return true;
|
|
29
26
|
}
|
|
30
27
|
has(element) {
|
|
31
|
-
return
|
|
28
|
+
return this._itemSet.has(element);
|
|
32
29
|
}
|
|
33
30
|
indexOf(element) {
|
|
34
|
-
if (!
|
|
31
|
+
if (!this._itemSet.has(element))
|
|
35
32
|
return -1;
|
|
36
|
-
return
|
|
33
|
+
return this._items.indexOf(element);
|
|
37
34
|
}
|
|
38
35
|
get(index) {
|
|
39
|
-
return
|
|
36
|
+
return this._items[index];
|
|
40
37
|
}
|
|
41
38
|
get size() {
|
|
42
|
-
return
|
|
39
|
+
return this._items.length;
|
|
43
40
|
}
|
|
44
|
-
[
|
|
45
|
-
return
|
|
41
|
+
[Symbol.iterator]() {
|
|
42
|
+
return this._items[Symbol.iterator]();
|
|
46
43
|
}
|
|
47
44
|
clear() {
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
this._items = [];
|
|
46
|
+
this._itemSet.clear();
|
|
50
47
|
}
|
|
51
48
|
find(predicate) {
|
|
52
|
-
return
|
|
49
|
+
return this._items.find(predicate);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
|
|
@@ -1,53 +1,50 @@
|
|
|
1
|
-
import { __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
|
|
2
|
-
|
|
3
|
-
var _IndexedSet_items, _IndexedSet_itemSet;
|
|
4
1
|
class IndexedSet {
|
|
5
2
|
constructor() {
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
this._items = [];
|
|
4
|
+
this._itemSet = new Set();
|
|
8
5
|
}
|
|
9
6
|
insertAt(index, ...elements) {
|
|
10
|
-
const newElements = elements.filter(e => !
|
|
7
|
+
const newElements = elements.filter(e => !this._itemSet.has(e));
|
|
11
8
|
if (newElements.length === 0)
|
|
12
9
|
return;
|
|
13
|
-
|
|
10
|
+
this._items.splice(index, 0, ...newElements);
|
|
14
11
|
for (const element of newElements) {
|
|
15
|
-
|
|
12
|
+
this._itemSet.add(element);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
15
|
delete(element) {
|
|
19
|
-
if (!
|
|
16
|
+
if (!this._itemSet.has(element))
|
|
20
17
|
return false;
|
|
21
|
-
const index =
|
|
18
|
+
const index = this._items.indexOf(element);
|
|
22
19
|
if (index >= 0) {
|
|
23
|
-
|
|
20
|
+
this._items.splice(index, 1);
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
this._itemSet.delete(element);
|
|
26
23
|
return true;
|
|
27
24
|
}
|
|
28
25
|
has(element) {
|
|
29
|
-
return
|
|
26
|
+
return this._itemSet.has(element);
|
|
30
27
|
}
|
|
31
28
|
indexOf(element) {
|
|
32
|
-
if (!
|
|
29
|
+
if (!this._itemSet.has(element))
|
|
33
30
|
return -1;
|
|
34
|
-
return
|
|
31
|
+
return this._items.indexOf(element);
|
|
35
32
|
}
|
|
36
33
|
get(index) {
|
|
37
|
-
return
|
|
34
|
+
return this._items[index];
|
|
38
35
|
}
|
|
39
36
|
get size() {
|
|
40
|
-
return
|
|
37
|
+
return this._items.length;
|
|
41
38
|
}
|
|
42
|
-
[
|
|
43
|
-
return
|
|
39
|
+
[Symbol.iterator]() {
|
|
40
|
+
return this._items[Symbol.iterator]();
|
|
44
41
|
}
|
|
45
42
|
clear() {
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
this._items = [];
|
|
44
|
+
this._itemSet.clear();
|
|
48
45
|
}
|
|
49
46
|
find(predicate) {
|
|
50
|
-
return
|
|
47
|
+
return this._items.find(predicate);
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
50
|
|