@react-stately/tree 3.8.4 → 3.8.6
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/TreeCollection.main.js +11 -5
- package/dist/TreeCollection.main.js.map +1 -1
- package/dist/TreeCollection.mjs +11 -5
- package/dist/TreeCollection.module.js +11 -5
- package/dist/TreeCollection.module.js.map +1 -1
- package/dist/types.d.ts +6 -6
- package/package.json +7 -7
- package/src/TreeCollection.ts +7 -7
|
@@ -26,11 +26,13 @@ $parcel$export(module.exports, "TreeCollection", () => $fae56b53b03726ff$export$
|
|
|
26
26
|
}
|
|
27
27
|
getKeyBefore(key) {
|
|
28
28
|
let node = this.keyMap.get(key);
|
|
29
|
-
|
|
29
|
+
var _node_prevKey;
|
|
30
|
+
return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
|
|
30
31
|
}
|
|
31
32
|
getKeyAfter(key) {
|
|
32
33
|
let node = this.keyMap.get(key);
|
|
33
|
-
|
|
34
|
+
var _node_nextKey;
|
|
35
|
+
return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
|
|
34
36
|
}
|
|
35
37
|
getFirstKey() {
|
|
36
38
|
return this.firstKey;
|
|
@@ -39,7 +41,8 @@ $parcel$export(module.exports, "TreeCollection", () => $fae56b53b03726ff$export$
|
|
|
39
41
|
return this.lastKey;
|
|
40
42
|
}
|
|
41
43
|
getItem(key) {
|
|
42
|
-
|
|
44
|
+
var _this_keyMap_get;
|
|
45
|
+
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
|
|
43
46
|
}
|
|
44
47
|
at(idx) {
|
|
45
48
|
const keys = [
|
|
@@ -49,6 +52,8 @@ $parcel$export(module.exports, "TreeCollection", () => $fae56b53b03726ff$export$
|
|
|
49
52
|
}
|
|
50
53
|
constructor(nodes, { expandedKeys: expandedKeys } = {}){
|
|
51
54
|
this.keyMap = new Map();
|
|
55
|
+
this.firstKey = null;
|
|
56
|
+
this.lastKey = null;
|
|
52
57
|
this.iterable = nodes;
|
|
53
58
|
expandedKeys = expandedKeys || new Set();
|
|
54
59
|
let visit = (node)=>{
|
|
@@ -56,7 +61,7 @@ $parcel$export(module.exports, "TreeCollection", () => $fae56b53b03726ff$export$
|
|
|
56
61
|
if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) for (let child of node.childNodes)visit(child);
|
|
57
62
|
};
|
|
58
63
|
for (let node of nodes)visit(node);
|
|
59
|
-
let last;
|
|
64
|
+
let last = null;
|
|
60
65
|
let index = 0;
|
|
61
66
|
for (let [key, node] of this.keyMap){
|
|
62
67
|
if (last) {
|
|
@@ -72,7 +77,8 @@ $parcel$export(module.exports, "TreeCollection", () => $fae56b53b03726ff$export$
|
|
|
72
77
|
// If it isn't the last node, last.nextKey will properly set at start of new loop
|
|
73
78
|
last.nextKey = undefined;
|
|
74
79
|
}
|
|
75
|
-
|
|
80
|
+
var _last_key;
|
|
81
|
+
this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAiDX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAE;QACrB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAiDX,CAAC,CAAC,OAAO,QAA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,SAAS,KAAK,UAAU,CAC/B,MAAM;QAGZ;QAEA,KAAK,IAAI,QAAQ,MACf,MAAM;QAGR,IAAI,OAAuB;QAC3B,IAAI,QAAQ;QACZ,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAE;YACnC,IAAI,MAAM;gBACR,KAAK,OAAO,GAAG;gBACf,KAAK,OAAO,GAAG,KAAK,GAAG;YACzB,OAAO;gBACL,IAAI,CAAC,QAAQ,GAAG;gBAChB,KAAK,OAAO,GAAG;YACjB;YAEA,IAAI,KAAK,IAAI,KAAK,QAChB,KAAK,KAAK,GAAG;YAGf,OAAO;YAEP,6DAA6D;YAC7D,iFAAiF;YACjF,KAAK,OAAO,GAAG;QACjB;YAEe;QAAf,IAAI,CAAC,OAAO,GAAG,CAAA,YAAA,iBAAA,2BAAA,KAAM,GAAG,cAAT,uBAAA,YAAa;IAC9B;AAwCF","sources":["packages/@react-stately/tree/src/TreeCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key, Node} from '@react-types/shared';\n\nexport class TreeCollection<T> implements Collection<Node<T>> {\n private keyMap: Map<Key, Node<T>> = new Map();\n private iterable: Iterable<Node<T>>;\n private firstKey: Key | null = null;\n private lastKey: Key | null = null;\n\n constructor(nodes: Iterable<Node<T>>, {expandedKeys}: {expandedKeys?: Set<Key>} = {}) {\n this.iterable = nodes;\n expandedKeys = expandedKeys || new Set();\n\n let visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) {\n for (let child of node.childNodes) {\n visit(child);\n }\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let last: Node<T> | null = null;\n let index = 0;\n for (let [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === 'item') {\n node.index = index++;\n }\n\n last = node;\n\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this.lastKey = last?.key ?? null;\n }\n\n *[Symbol.iterator]() {\n yield* this.iterable;\n }\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n return this.lastKey;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n}\n"],"names":[],"version":3,"file":"TreeCollection.main.js.map"}
|
package/dist/TreeCollection.mjs
CHANGED
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
}
|
|
21
21
|
getKeyBefore(key) {
|
|
22
22
|
let node = this.keyMap.get(key);
|
|
23
|
-
|
|
23
|
+
var _node_prevKey;
|
|
24
|
+
return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
|
|
24
25
|
}
|
|
25
26
|
getKeyAfter(key) {
|
|
26
27
|
let node = this.keyMap.get(key);
|
|
27
|
-
|
|
28
|
+
var _node_nextKey;
|
|
29
|
+
return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
|
|
28
30
|
}
|
|
29
31
|
getFirstKey() {
|
|
30
32
|
return this.firstKey;
|
|
@@ -33,7 +35,8 @@
|
|
|
33
35
|
return this.lastKey;
|
|
34
36
|
}
|
|
35
37
|
getItem(key) {
|
|
36
|
-
|
|
38
|
+
var _this_keyMap_get;
|
|
39
|
+
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
|
|
37
40
|
}
|
|
38
41
|
at(idx) {
|
|
39
42
|
const keys = [
|
|
@@ -43,6 +46,8 @@
|
|
|
43
46
|
}
|
|
44
47
|
constructor(nodes, { expandedKeys: expandedKeys } = {}){
|
|
45
48
|
this.keyMap = new Map();
|
|
49
|
+
this.firstKey = null;
|
|
50
|
+
this.lastKey = null;
|
|
46
51
|
this.iterable = nodes;
|
|
47
52
|
expandedKeys = expandedKeys || new Set();
|
|
48
53
|
let visit = (node)=>{
|
|
@@ -50,7 +55,7 @@
|
|
|
50
55
|
if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) for (let child of node.childNodes)visit(child);
|
|
51
56
|
};
|
|
52
57
|
for (let node of nodes)visit(node);
|
|
53
|
-
let last;
|
|
58
|
+
let last = null;
|
|
54
59
|
let index = 0;
|
|
55
60
|
for (let [key, node] of this.keyMap){
|
|
56
61
|
if (last) {
|
|
@@ -66,7 +71,8 @@
|
|
|
66
71
|
// If it isn't the last node, last.nextKey will properly set at start of new loop
|
|
67
72
|
last.nextKey = undefined;
|
|
68
73
|
}
|
|
69
|
-
|
|
74
|
+
var _last_key;
|
|
75
|
+
this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
}
|
|
21
21
|
getKeyBefore(key) {
|
|
22
22
|
let node = this.keyMap.get(key);
|
|
23
|
-
|
|
23
|
+
var _node_prevKey;
|
|
24
|
+
return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
|
|
24
25
|
}
|
|
25
26
|
getKeyAfter(key) {
|
|
26
27
|
let node = this.keyMap.get(key);
|
|
27
|
-
|
|
28
|
+
var _node_nextKey;
|
|
29
|
+
return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
|
|
28
30
|
}
|
|
29
31
|
getFirstKey() {
|
|
30
32
|
return this.firstKey;
|
|
@@ -33,7 +35,8 @@
|
|
|
33
35
|
return this.lastKey;
|
|
34
36
|
}
|
|
35
37
|
getItem(key) {
|
|
36
|
-
|
|
38
|
+
var _this_keyMap_get;
|
|
39
|
+
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
|
|
37
40
|
}
|
|
38
41
|
at(idx) {
|
|
39
42
|
const keys = [
|
|
@@ -43,6 +46,8 @@
|
|
|
43
46
|
}
|
|
44
47
|
constructor(nodes, { expandedKeys: expandedKeys } = {}){
|
|
45
48
|
this.keyMap = new Map();
|
|
49
|
+
this.firstKey = null;
|
|
50
|
+
this.lastKey = null;
|
|
46
51
|
this.iterable = nodes;
|
|
47
52
|
expandedKeys = expandedKeys || new Set();
|
|
48
53
|
let visit = (node)=>{
|
|
@@ -50,7 +55,7 @@
|
|
|
50
55
|
if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) for (let child of node.childNodes)visit(child);
|
|
51
56
|
};
|
|
52
57
|
for (let node of nodes)visit(node);
|
|
53
|
-
let last;
|
|
58
|
+
let last = null;
|
|
54
59
|
let index = 0;
|
|
55
60
|
for (let [key, node] of this.keyMap){
|
|
56
61
|
if (last) {
|
|
@@ -66,7 +71,8 @@
|
|
|
66
71
|
// If it isn't the last node, last.nextKey will properly set at start of new loop
|
|
67
72
|
last.nextKey = undefined;
|
|
68
73
|
}
|
|
69
|
-
|
|
74
|
+
var _last_key;
|
|
75
|
+
this.lastKey = (_last_key = last === null || last === void 0 ? void 0 :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AwB;IACjC;IAEA,GAAG,GAAW,EAAE;QACd,MAAM,OAAO;eAAI,IAAI,CAAC,OAAO;SAAG;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;IAC/B;IAhFA,YAAY,KAAwB,EAAE,gBAAC,YAAY,EAA4B,GAAG,CAAC,CAAC,CAAE;aAL9E,SAA4B,IAAI;aAEhC,WAAuB;aACvB,UAAsB;QAG5B,IAAI,CAAC,QAAQ,GAAG;QAChB,eAAe,gBAAgB,IAAI;QAEnC,IAAI,QAAQ,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE;YAE1B,IAAI,KAAK,UAAU,IAAK,CAAA,KAAK,IAAI,KAAK,aAAa,aAAa,GAAG,CAAC,KAAK,GAAG,CAAA,GAC1E,KAAK,IAAI,SAAS,KAAK,UAAU,CAC/B,MAAM;QAGZ;QAEA,KAAK,IAAI,QAAQ,MACf,MAAM;QAGR,IAAI,OAAuB;QAC3B,IAAI,QAAQ;QACZ,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAE;YACnC,IAAI,MAAM;gBACR,KAAK,OAAO,GAAG;gBACf,KAAK,OAAO,GAAG,KAAK,GAAG;YACzB,OAAO;gBACL,IAAI,CAAC,QAAQ,GAAG;gBAChB,KAAK,OAAO,GAAG;YACjB;YAEA,IAAI,KAAK,IAAI,KAAK,QAChB,KAAK,KAAK,GAAG;YAGf,OAAO;YAEP,6DAA6D;YAC7D,iFAAiF;YACjF,KAAK,OAAO,GAAG;QACjB;YAEe;QAAf,IAAI,CAAC,OAAO,GAAG,CAAA,YAAA,iBAAA,2BAAA,KAAM,GAAG,cAAT,uBAAA,YAAa;IAC9B;AAwCF","sources":["packages/@react-stately/tree/src/TreeCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key, Node} from '@react-types/shared';\n\nexport class TreeCollection<T> implements Collection<Node<T>> {\n private keyMap: Map<Key, Node<T>> = new Map();\n private iterable: Iterable<Node<T>>;\n private firstKey: Key | null = null;\n private lastKey: Key | null = null;\n\n constructor(nodes: Iterable<Node<T>>, {expandedKeys}: {expandedKeys?: Set<Key>} = {}) {\n this.iterable = nodes;\n expandedKeys = expandedKeys || new Set();\n\n let visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) {\n for (let child of node.childNodes) {\n visit(child);\n }\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let last: Node<T> | null = null;\n let index = 0;\n for (let [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === 'item') {\n node.index = index++;\n }\n\n last = node;\n\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this.lastKey = last?.key ?? null;\n }\n\n *[Symbol.iterator]() {\n yield* this.iterable;\n }\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n return this.lastKey;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n}\n"],"names":[],"version":3,"file":"TreeCollection.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -7,12 +7,12 @@ export class TreeCollection<T> implements Collection<Node<T>> {
|
|
|
7
7
|
[Symbol.iterator](): Generator<Node<T>, void, undefined>;
|
|
8
8
|
get size(): number;
|
|
9
9
|
getKeys(): IterableIterator<Key>;
|
|
10
|
-
getKeyBefore(key: Key): Key;
|
|
11
|
-
getKeyAfter(key: Key): Key;
|
|
12
|
-
getFirstKey(): Key;
|
|
13
|
-
getLastKey(): Key;
|
|
14
|
-
getItem(key: Key): Node<T
|
|
15
|
-
at(idx: number): Node<T
|
|
10
|
+
getKeyBefore(key: Key): Key | null;
|
|
11
|
+
getKeyAfter(key: Key): Key | null;
|
|
12
|
+
getFirstKey(): Key | null;
|
|
13
|
+
getLastKey(): Key | null;
|
|
14
|
+
getItem(key: Key): Node<T> | null;
|
|
15
|
+
at(idx: number): Node<T> | null;
|
|
16
16
|
}
|
|
17
17
|
export interface TreeProps<T> extends CollectionStateBase<T>, Expandable, MultipleSelection {
|
|
18
18
|
/** Whether `disabledKeys` applies to all interactions, or only selection. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/tree",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.6",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-stately/collections": "^3.
|
|
26
|
-
"@react-stately/selection": "^3.
|
|
27
|
-
"@react-stately/utils": "^3.10.
|
|
28
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-stately/collections": "^3.12.0",
|
|
26
|
+
"@react-stately/selection": "^3.18.0",
|
|
27
|
+
"@react-stately/utils": "^3.10.5",
|
|
28
|
+
"@react-types/shared": "^3.26.0",
|
|
29
29
|
"@swc/helpers": "^0.5.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
32
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
|
|
38
38
|
}
|
package/src/TreeCollection.ts
CHANGED
|
@@ -15,8 +15,8 @@ import {Collection, Key, Node} from '@react-types/shared';
|
|
|
15
15
|
export class TreeCollection<T> implements Collection<Node<T>> {
|
|
16
16
|
private keyMap: Map<Key, Node<T>> = new Map();
|
|
17
17
|
private iterable: Iterable<Node<T>>;
|
|
18
|
-
private firstKey: Key;
|
|
19
|
-
private lastKey: Key;
|
|
18
|
+
private firstKey: Key | null = null;
|
|
19
|
+
private lastKey: Key | null = null;
|
|
20
20
|
|
|
21
21
|
constructor(nodes: Iterable<Node<T>>, {expandedKeys}: {expandedKeys?: Set<Key>} = {}) {
|
|
22
22
|
this.iterable = nodes;
|
|
@@ -36,7 +36,7 @@ export class TreeCollection<T> implements Collection<Node<T>> {
|
|
|
36
36
|
visit(node);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
let last: Node<T
|
|
39
|
+
let last: Node<T> | null = null;
|
|
40
40
|
let index = 0;
|
|
41
41
|
for (let [key, node] of this.keyMap) {
|
|
42
42
|
if (last) {
|
|
@@ -58,7 +58,7 @@ export class TreeCollection<T> implements Collection<Node<T>> {
|
|
|
58
58
|
last.nextKey = undefined;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
this.lastKey = last?.key;
|
|
61
|
+
this.lastKey = last?.key ?? null;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
*[Symbol.iterator]() {
|
|
@@ -75,12 +75,12 @@ export class TreeCollection<T> implements Collection<Node<T>> {
|
|
|
75
75
|
|
|
76
76
|
getKeyBefore(key: Key) {
|
|
77
77
|
let node = this.keyMap.get(key);
|
|
78
|
-
return node ? node.prevKey : null;
|
|
78
|
+
return node ? node.prevKey ?? null : null;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
getKeyAfter(key: Key) {
|
|
82
82
|
let node = this.keyMap.get(key);
|
|
83
|
-
return node ? node.nextKey : null;
|
|
83
|
+
return node ? node.nextKey ?? null : null;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
getFirstKey() {
|
|
@@ -92,7 +92,7 @@ export class TreeCollection<T> implements Collection<Node<T>> {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
getItem(key: Key) {
|
|
95
|
-
return this.keyMap.get(key);
|
|
95
|
+
return this.keyMap.get(key) ?? null;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
at(idx: number) {
|