list-toolkit 2.2.6 → 2.3.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/README.md +40 -37
- package/llms-full.txt +743 -0
- package/llms.txt +100 -0
- package/package.json +34 -29
- package/src/cache/cache-fifo.d.ts +6 -0
- package/src/cache/cache-fifo.js +7 -4
- package/src/cache/cache-lfu.d.ts +18 -0
- package/src/cache/cache-lfu.js +18 -6
- package/src/cache/cache-lru.d.ts +74 -0
- package/src/cache/cache-lru.js +60 -5
- package/src/cache/cache-random.d.ts +20 -0
- package/src/cache/cache-random.js +17 -6
- package/src/cache/decorator.d.ts +46 -0
- package/src/cache/decorator.js +26 -2
- package/src/cache.d.ts +13 -0
- package/src/cache.js +7 -2
- package/src/ext-list.d.ts +3 -0
- package/src/ext-list.js +0 -2
- package/src/ext-slist.d.ts +3 -0
- package/src/ext-slist.js +0 -2
- package/src/ext-value-list.d.ts +3 -0
- package/src/ext-value-list.js +0 -2
- package/src/ext-value-slist.d.ts +3 -0
- package/src/ext-value-slist.js +0 -2
- package/src/heap/basics.d.ts +89 -0
- package/src/heap/basics.js +42 -5
- package/src/heap/leftist-heap.d.ts +107 -0
- package/src/heap/leftist-heap.js +54 -2
- package/src/heap/min-heap.d.ts +270 -0
- package/src/heap/min-heap.js +186 -2
- package/src/heap/skew-heap.d.ts +105 -0
- package/src/heap/skew-heap.js +54 -2
- package/src/heap.d.ts +3 -0
- package/src/heap.js +0 -2
- package/src/list/basics.d.ts +43 -0
- package/src/list/basics.js +26 -8
- package/src/list/core.d.ts +271 -0
- package/src/list/core.js +162 -7
- package/src/list/ext-value.d.ts +253 -0
- package/src/list/ext-value.js +40 -6
- package/src/list/ext.d.ts +242 -0
- package/src/list/ext.js +148 -10
- package/src/list/nodes.d.ts +336 -0
- package/src/list/nodes.js +141 -3
- package/src/list/ptr.d.ts +72 -0
- package/src/list/ptr.js +44 -2
- package/src/list/value.d.ts +292 -0
- package/src/list/value.js +47 -6
- package/src/list-helpers.d.ts +44 -0
- package/src/list-helpers.js +36 -3
- package/src/list-utils.d.ts +141 -0
- package/src/list-utils.js +89 -3
- package/src/list.d.ts +3 -0
- package/src/list.js +0 -2
- package/src/meta-utils.d.ts +212 -0
- package/src/meta-utils.js +152 -1
- package/src/nt-utils.d.ts +91 -0
- package/src/nt-utils.js +65 -4
- package/src/queue.d.ts +74 -0
- package/src/queue.js +28 -2
- package/src/slist/basics.d.ts +47 -0
- package/src/slist/basics.js +23 -8
- package/src/slist/core.d.ts +251 -0
- package/src/slist/core.js +151 -6
- package/src/slist/ext-value.d.ts +188 -0
- package/src/slist/ext-value.js +35 -6
- package/src/slist/ext.d.ts +182 -0
- package/src/slist/ext.js +114 -12
- package/src/slist/nodes.d.ts +361 -0
- package/src/slist/nodes.js +156 -3
- package/src/slist/ptr.d.ts +73 -0
- package/src/slist/ptr.js +45 -2
- package/src/slist/value.d.ts +246 -0
- package/src/slist/value.js +38 -6
- package/src/slist.d.ts +3 -0
- package/src/slist.js +0 -2
- package/src/stack.d.ts +59 -0
- package/src/stack.js +29 -3
- package/src/tree/splay-tree.d.ts +151 -0
- package/src/tree/splay-tree.js +94 -3
- package/src/value-list.d.ts +3 -0
- package/src/value-list.js +0 -2
- package/src/value-slist.d.ts +3 -0
- package/src/value-slist.js +0 -2
- package/cjs/cache/cache-fifo.js +0 -37
- package/cjs/cache/cache-lfu.js +0 -76
- package/cjs/cache/cache-lru.js +0 -100
- package/cjs/cache/cache-random.js +0 -77
- package/cjs/cache/decorator.js +0 -47
- package/cjs/cache.js +0 -27
- package/cjs/ext-list.js +0 -21
- package/cjs/ext-slist.js +0 -21
- package/cjs/ext-value-list.js +0 -21
- package/cjs/ext-value-slist.js +0 -21
- package/cjs/heap/basics.js +0 -63
- package/cjs/heap/leftist-heap.js +0 -124
- package/cjs/heap/min-heap.js +0 -294
- package/cjs/heap/skew-heap.js +0 -114
- package/cjs/heap.js +0 -21
- package/cjs/list/basics.js +0 -88
- package/cjs/list/core.js +0 -305
- package/cjs/list/ext-value.js +0 -88
- package/cjs/list/ext.js +0 -356
- package/cjs/list/nodes.js +0 -240
- package/cjs/list/ptr.js +0 -61
- package/cjs/list/value.js +0 -99
- package/cjs/list-helpers.js +0 -91
- package/cjs/list-utils.js +0 -141
- package/cjs/list.js +0 -21
- package/cjs/meta-utils.js +0 -171
- package/cjs/nt-utils.js +0 -132
- package/cjs/package.json +0 -1
- package/cjs/queue.js +0 -58
- package/cjs/slist/basics.js +0 -71
- package/cjs/slist/core.js +0 -362
- package/cjs/slist/ext-value.js +0 -82
- package/cjs/slist/ext.js +0 -336
- package/cjs/slist/nodes.js +0 -276
- package/cjs/slist/ptr.js +0 -87
- package/cjs/slist/value.js +0 -90
- package/cjs/slist.js +0 -21
- package/cjs/stack.js +0 -55
- package/cjs/tree/splay-tree.js +0 -362
- package/cjs/value-list.js +0 -21
- package/cjs/value-slist.js +0 -21
package/cjs/list/basics.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// useful low-level operations on doubly linked lists
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.splice = exports.pop = exports.extract = exports.append = void 0;
|
|
8
|
-
const extract = ({
|
|
9
|
-
nextName,
|
|
10
|
-
prevName
|
|
11
|
-
}, {
|
|
12
|
-
from,
|
|
13
|
-
to = from
|
|
14
|
-
}) => {
|
|
15
|
-
const next = to[nextName],
|
|
16
|
-
prev = from[prevName];
|
|
17
|
-
|
|
18
|
-
// extract
|
|
19
|
-
prev[nextName] = next;
|
|
20
|
-
next[prevName] = prev;
|
|
21
|
-
|
|
22
|
-
// clear
|
|
23
|
-
from[prevName] = to;
|
|
24
|
-
to[nextName] = from;
|
|
25
|
-
return {
|
|
26
|
-
extracted: from,
|
|
27
|
-
rest: next === from ? null : next
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// pop(options, head).node === extract(options, {from: node})
|
|
32
|
-
exports.extract = extract;
|
|
33
|
-
const pop = ({
|
|
34
|
-
nextName,
|
|
35
|
-
prevName
|
|
36
|
-
}, node) => {
|
|
37
|
-
const next = node[nextName],
|
|
38
|
-
prev = node[prevName];
|
|
39
|
-
|
|
40
|
-
// extract
|
|
41
|
-
prev[nextName] = next;
|
|
42
|
-
next[prevName] = prev;
|
|
43
|
-
|
|
44
|
-
// clear
|
|
45
|
-
node[prevName] = node[nextName] = node;
|
|
46
|
-
return {
|
|
47
|
-
extracted: node,
|
|
48
|
-
rest: next === node ? null : next
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
exports.pop = pop;
|
|
52
|
-
const splice = ({
|
|
53
|
-
nextName,
|
|
54
|
-
prevName
|
|
55
|
-
}, target, circularList) => {
|
|
56
|
-
const next = target[nextName],
|
|
57
|
-
from = circularList,
|
|
58
|
-
to = from[prevName];
|
|
59
|
-
|
|
60
|
-
// splice
|
|
61
|
-
target[nextName] = from;
|
|
62
|
-
from[prevName] = target;
|
|
63
|
-
to[nextName] = next;
|
|
64
|
-
next[prevName] = to;
|
|
65
|
-
return target;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// append(options, target, range) === splice(options, target, extract(options, range))
|
|
69
|
-
exports.splice = splice;
|
|
70
|
-
const append = ({
|
|
71
|
-
nextName,
|
|
72
|
-
prevName
|
|
73
|
-
}, target, {
|
|
74
|
-
from,
|
|
75
|
-
to = from
|
|
76
|
-
}) => {
|
|
77
|
-
// extract
|
|
78
|
-
from[prevName][nextName] = to[nextName];
|
|
79
|
-
to[nextName][prevName] = from[prevName];
|
|
80
|
-
|
|
81
|
-
// splice
|
|
82
|
-
to[nextName] = target[nextName];
|
|
83
|
-
to[nextName][prevName] = to;
|
|
84
|
-
target[nextName] = from;
|
|
85
|
-
from[prevName] = target;
|
|
86
|
-
return target;
|
|
87
|
-
};
|
|
88
|
-
exports.append = append;
|
package/cjs/list/core.js
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.List = void 0;
|
|
7
|
-
Object.defineProperty(exports, "Ptr", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _ptr.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
exports.default = void 0;
|
|
14
|
-
var _nodes = require("./nodes.js");
|
|
15
|
-
var _basics = require("./basics.js");
|
|
16
|
-
var _ptr = _interopRequireDefault(require("./ptr.js"));
|
|
17
|
-
var _metaUtils = require("../meta-utils.js");
|
|
18
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
-
class List extends _nodes.HeadNode {
|
|
20
|
-
get frontPtr() {
|
|
21
|
-
return new _ptr.default(this, this.front);
|
|
22
|
-
}
|
|
23
|
-
get backPtr() {
|
|
24
|
-
return new _ptr.default(this, this.back);
|
|
25
|
-
}
|
|
26
|
-
makePtr(node) {
|
|
27
|
-
if (node && !this.isNodeLike(node)) throw new Error('"node" is not a compatible node');
|
|
28
|
-
return new _ptr.default(this, node || this.front);
|
|
29
|
-
}
|
|
30
|
-
makePtrFromPrev(prev) {
|
|
31
|
-
if (prev && !this.isNodeLike(prev)) throw new Error('"prev" is not a compatible node');
|
|
32
|
-
return new _ptr.default(this, prev ? prev[this.nextName] : this.front);
|
|
33
|
-
}
|
|
34
|
-
pushFront(value) {
|
|
35
|
-
const node = this.adoptValue(value);
|
|
36
|
-
(0, _basics.splice)(this, this, node);
|
|
37
|
-
return this.makePtr(node);
|
|
38
|
-
}
|
|
39
|
-
pushBack(value) {
|
|
40
|
-
const node = this.adoptValue(value);
|
|
41
|
-
(0, _basics.splice)(this, this[this.prevName], node);
|
|
42
|
-
return this.makePtr(node);
|
|
43
|
-
}
|
|
44
|
-
popFrontNode() {
|
|
45
|
-
if (!this.isEmpty) return (0, _basics.pop)(this, this[this.nextName]).extracted;
|
|
46
|
-
}
|
|
47
|
-
popBackNode() {
|
|
48
|
-
if (!this.isEmpty) return (0, _basics.pop)(this, this[this.prevName]).extracted;
|
|
49
|
-
}
|
|
50
|
-
pushFrontNode(nodeOrPtr) {
|
|
51
|
-
const node = this.adoptNode(nodeOrPtr);
|
|
52
|
-
(0, _basics.splice)(this, this, node);
|
|
53
|
-
return this.makePtr(node);
|
|
54
|
-
}
|
|
55
|
-
pushBackNode(nodeOrPtr) {
|
|
56
|
-
const node = this.adoptNode(nodeOrPtr);
|
|
57
|
-
(0, _basics.splice)(this, this[this.prevName], node);
|
|
58
|
-
return this.makePtr(node);
|
|
59
|
-
}
|
|
60
|
-
appendFront(list) {
|
|
61
|
-
if (!this.isCompatible(list)) throw new Error('Incompatible lists');
|
|
62
|
-
if (list.isEmpty) return this;
|
|
63
|
-
const head = list[this.nextName];
|
|
64
|
-
(0, _basics.append)(this, this, {
|
|
65
|
-
from: head,
|
|
66
|
-
to: list[this.prevName]
|
|
67
|
-
});
|
|
68
|
-
return this.makePtr();
|
|
69
|
-
}
|
|
70
|
-
appendBack(list) {
|
|
71
|
-
if (!this.isCompatible(list)) throw new Error('Incompatible lists');
|
|
72
|
-
if (list.isEmpty) return this;
|
|
73
|
-
const head = list[this.nextName];
|
|
74
|
-
(0, _basics.append)(this, this[this.prevName], {
|
|
75
|
-
from: head,
|
|
76
|
-
to: list[this.prevName]
|
|
77
|
-
});
|
|
78
|
-
return this.makePtr(head);
|
|
79
|
-
}
|
|
80
|
-
moveToFront(nodeOrPtr) {
|
|
81
|
-
const node = this.normalizeNode(nodeOrPtr);
|
|
82
|
-
if (this[this.nextName] !== node) {
|
|
83
|
-
(0, _basics.splice)(this, this, (0, _basics.pop)(this, node).extracted);
|
|
84
|
-
}
|
|
85
|
-
return this.frontPtr;
|
|
86
|
-
}
|
|
87
|
-
moveToBack(nodeOrPtr) {
|
|
88
|
-
const node = this.normalizeNode(nodeOrPtr);
|
|
89
|
-
if (this[this.prevName] !== node) {
|
|
90
|
-
(0, _basics.splice)(this, this[this.prevName], (0, _basics.pop)(this, node).extracted);
|
|
91
|
-
}
|
|
92
|
-
return this.backPtr;
|
|
93
|
-
}
|
|
94
|
-
clear(drop) {
|
|
95
|
-
if (drop) {
|
|
96
|
-
while (!this.isEmpty) this.popFrontNode();
|
|
97
|
-
} else {
|
|
98
|
-
this[this.nextName] = this[this.prevName] = this;
|
|
99
|
-
}
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
removeNode(nodeOrPtr) {
|
|
103
|
-
return (0, _basics.pop)(this, this.normalizeNode(nodeOrPtr)).extracted;
|
|
104
|
-
}
|
|
105
|
-
removeRange(range, drop) {
|
|
106
|
-
return this.extractRange(range).clear(drop);
|
|
107
|
-
}
|
|
108
|
-
extractRange(range = {}) {
|
|
109
|
-
range = this.normalizeRange(range);
|
|
110
|
-
range.from ||= this.front;
|
|
111
|
-
range.to ||= this.back;
|
|
112
|
-
return (0, _basics.append)(this, this.make(), range);
|
|
113
|
-
}
|
|
114
|
-
extractBy(condition) {
|
|
115
|
-
const extracted = this.make();
|
|
116
|
-
if (this.isEmpty) return extracted;
|
|
117
|
-
while (this.isEmpty && condition(this.front)) extracted.pushBack(this.popFront());
|
|
118
|
-
if (this.isOneOrEmpty) return extracted;
|
|
119
|
-
for (const ptr of this.getPtrIterator({
|
|
120
|
-
from: this.front[this.nextName]
|
|
121
|
-
})) {
|
|
122
|
-
if (condition(ptr.node)) extracted.pushBack(ptr.removeCurrent());
|
|
123
|
-
}
|
|
124
|
-
return extracted;
|
|
125
|
-
}
|
|
126
|
-
reverse() {
|
|
127
|
-
let current = this;
|
|
128
|
-
do {
|
|
129
|
-
const next = current[this.nextName];
|
|
130
|
-
current[this.nextName] = current[this.prevName];
|
|
131
|
-
current[this.prevName] = next;
|
|
132
|
-
current = next;
|
|
133
|
-
} while (current !== this);
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
sort(lessFn) {
|
|
137
|
-
if (this.isOneOrEmpty) return this;
|
|
138
|
-
const left = this.make(),
|
|
139
|
-
right = this.make();
|
|
140
|
-
|
|
141
|
-
// split into two sublists
|
|
142
|
-
for (let isLeft = true; !this.isEmpty; isLeft = !isLeft) {
|
|
143
|
-
(isLeft ? left : right).pushBackNode(this.popFrontNode());
|
|
144
|
-
}
|
|
145
|
-
// the list is empty now
|
|
146
|
-
|
|
147
|
-
// sort sublists
|
|
148
|
-
left.sort(lessFn);
|
|
149
|
-
right.sort(lessFn);
|
|
150
|
-
|
|
151
|
-
// merge sublists
|
|
152
|
-
while (!left.isEmpty && !right.isEmpty) {
|
|
153
|
-
this.pushBackNode((lessFn(left.front, right.front) ? left : right).popFrontNode());
|
|
154
|
-
}
|
|
155
|
-
if (!left.isEmpty) this.appendBack(left);
|
|
156
|
-
if (!right.isEmpty) this.appendBack(right);
|
|
157
|
-
return this;
|
|
158
|
-
}
|
|
159
|
-
releaseRawList() {
|
|
160
|
-
return this.isEmpty ? null : (0, _basics.pop)(this, this).rest;
|
|
161
|
-
}
|
|
162
|
-
releaseNTList() {
|
|
163
|
-
if (this.isEmpty) return null;
|
|
164
|
-
const head = this[this.nextName],
|
|
165
|
-
tail = this[this.prevName];
|
|
166
|
-
this.clear();
|
|
167
|
-
head[this.prevName] = tail[this.nextName] = null;
|
|
168
|
-
return {
|
|
169
|
-
head,
|
|
170
|
-
tail
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
validateRange(range = {}) {
|
|
174
|
-
range = this.normalizeRange(range);
|
|
175
|
-
let current = range.from;
|
|
176
|
-
do {
|
|
177
|
-
if (current === this) return false;
|
|
178
|
-
current = current[this.nextName];
|
|
179
|
-
} while (current !== range.to);
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// iterators
|
|
184
|
-
|
|
185
|
-
[Symbol.iterator]() {
|
|
186
|
-
let current = this[this.nextName],
|
|
187
|
-
readyToStop = this.isEmpty;
|
|
188
|
-
return (0, _metaUtils.normalizeIterator)({
|
|
189
|
-
next: () => {
|
|
190
|
-
if (readyToStop && current === this) return {
|
|
191
|
-
done: true
|
|
192
|
-
};
|
|
193
|
-
readyToStop = true;
|
|
194
|
-
const value = current;
|
|
195
|
-
current = current[this.nextName];
|
|
196
|
-
return {
|
|
197
|
-
value
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
getNodeIterator(range = {}) {
|
|
203
|
-
range = this.normalizeRange(range);
|
|
204
|
-
const {
|
|
205
|
-
from,
|
|
206
|
-
to
|
|
207
|
-
} = range;
|
|
208
|
-
return {
|
|
209
|
-
[Symbol.iterator]: () => {
|
|
210
|
-
let current = from || this[this.nextName],
|
|
211
|
-
readyToStop = this.isEmpty;
|
|
212
|
-
const stop = to ? to[this.nextName] : this;
|
|
213
|
-
return (0, _metaUtils.normalizeIterator)({
|
|
214
|
-
next: () => {
|
|
215
|
-
if (readyToStop && current === stop) return {
|
|
216
|
-
done: true
|
|
217
|
-
};
|
|
218
|
-
readyToStop = true;
|
|
219
|
-
const value = current;
|
|
220
|
-
current = current[this.nextName];
|
|
221
|
-
return {
|
|
222
|
-
value
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
getPtrIterator(range) {
|
|
230
|
-
return (0, _metaUtils.mapIterator)(this.getNodeIterator(range), node => new _ptr.default(this, node));
|
|
231
|
-
}
|
|
232
|
-
getReverseNodeIterator(range = {}) {
|
|
233
|
-
range = this.normalizeRange(range);
|
|
234
|
-
const {
|
|
235
|
-
from,
|
|
236
|
-
to
|
|
237
|
-
} = range;
|
|
238
|
-
return {
|
|
239
|
-
[Symbol.iterator]: () => {
|
|
240
|
-
let current = to || this[this.prevName],
|
|
241
|
-
readyToStop = this.isEmpty;
|
|
242
|
-
const stop = from ? from[this.prevName] : this;
|
|
243
|
-
return (0, _metaUtils.normalizeIterator)({
|
|
244
|
-
next: () => {
|
|
245
|
-
if (readyToStop && current === stop) return {
|
|
246
|
-
done: true
|
|
247
|
-
};
|
|
248
|
-
readyToStop = true;
|
|
249
|
-
const value = current;
|
|
250
|
-
current = current[this.prevName];
|
|
251
|
-
return {
|
|
252
|
-
value
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
getReversePtrIterator(range) {
|
|
260
|
-
return (0, _metaUtils.mapIterator)(this.getReverseNodeIterator(range), node => new _ptr.default(this, node));
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// meta helpers
|
|
264
|
-
|
|
265
|
-
make() {
|
|
266
|
-
return new List(this);
|
|
267
|
-
}
|
|
268
|
-
makeFrom(values) {
|
|
269
|
-
return List.from(values, this);
|
|
270
|
-
}
|
|
271
|
-
makeFromRange(range) {
|
|
272
|
-
return List.fromRange(range, this);
|
|
273
|
-
}
|
|
274
|
-
static from(values, options) {
|
|
275
|
-
const list = new List(options);
|
|
276
|
-
for (const value of values) list.pushBack(value);
|
|
277
|
-
return list;
|
|
278
|
-
}
|
|
279
|
-
static fromRange(range, options) {
|
|
280
|
-
const list = new List(options);
|
|
281
|
-
if (!range) return list;
|
|
282
|
-
range = list.normalizeRange(range);
|
|
283
|
-
if (!range.from || !range.to) throw new Error('"range" should be fully specified');
|
|
284
|
-
return (0, _basics.append)(list, list, range);
|
|
285
|
-
}
|
|
286
|
-
static fromExtList(extList) {
|
|
287
|
-
if (!(extList instanceof _nodes.ExtListBase)) throw new Error('Not a circular list');
|
|
288
|
-
const list = new List(extList);
|
|
289
|
-
if (extList.isEmpty) return list;
|
|
290
|
-
(0, _basics.splice)(list, list, extList.head);
|
|
291
|
-
extList.clear();
|
|
292
|
-
return list;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
exports.List = List;
|
|
296
|
-
List.Ptr = _ptr.default;
|
|
297
|
-
(0, _metaUtils.addAliases)(List.prototype, {
|
|
298
|
-
popFrontNode: 'popFront, pop',
|
|
299
|
-
popBackNode: 'popBack',
|
|
300
|
-
pushFront: 'push',
|
|
301
|
-
getNodeIterator: 'getIterator',
|
|
302
|
-
getReverseNodeIterator: 'getReverseIterator',
|
|
303
|
-
appendBack: 'append'
|
|
304
|
-
});
|
|
305
|
-
var _default = exports.default = List;
|
package/cjs/list/ext-value.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ExtValueList = void 0;
|
|
7
|
-
Object.defineProperty(exports, "ValueNode", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _nodes.ValueNode;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
exports.default = void 0;
|
|
14
|
-
var _ext = _interopRequireWildcard(require("./ext.js"));
|
|
15
|
-
var _nodes = require("./nodes.js");
|
|
16
|
-
var _metaUtils = require("../meta-utils.js");
|
|
17
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
-
class ExtValueList extends _ext.default {
|
|
19
|
-
adoptValue(value) {
|
|
20
|
-
if (value instanceof _ext.Ptr) {
|
|
21
|
-
if (!this.isCompatiblePtr(value)) throw new Error('Incompatible pointer');
|
|
22
|
-
if (value.node instanceof _nodes.ValueNode) {
|
|
23
|
-
value.list = this;
|
|
24
|
-
return super.adoptNode(value);
|
|
25
|
-
}
|
|
26
|
-
return new _nodes.ValueNode(value.node, this);
|
|
27
|
-
}
|
|
28
|
-
if (value instanceof _nodes.ValueNode) {
|
|
29
|
-
if (!this.isNodeLike(value)) throw new Error('Incompatible node');
|
|
30
|
-
return super.adoptNode(value);
|
|
31
|
-
}
|
|
32
|
-
return new _nodes.ValueNode(value, this);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// iterators
|
|
36
|
-
|
|
37
|
-
[Symbol.iterator]() {
|
|
38
|
-
let current = this.head,
|
|
39
|
-
readyToStop = this.isEmpty;
|
|
40
|
-
return (0, _metaUtils.normalizeIterator)({
|
|
41
|
-
next: () => {
|
|
42
|
-
if (readyToStop && current === this.head) return {
|
|
43
|
-
done: true
|
|
44
|
-
};
|
|
45
|
-
readyToStop = true;
|
|
46
|
-
const value = current.value;
|
|
47
|
-
current = current[this.nextName];
|
|
48
|
-
return {
|
|
49
|
-
value
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
getValueIterator(range) {
|
|
55
|
-
return (0, _metaUtils.mapIterator)(this.getNodeIterator(range), node => node.value);
|
|
56
|
-
}
|
|
57
|
-
getReverseValueIterator(range) {
|
|
58
|
-
return (0, _metaUtils.mapIterator)(this.getReverseNodeIterator(range), node => node.value);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// meta helpers
|
|
62
|
-
|
|
63
|
-
clone() {
|
|
64
|
-
return new ExtValueList(this);
|
|
65
|
-
}
|
|
66
|
-
make(head = null) {
|
|
67
|
-
return new ExtValueList(head, this);
|
|
68
|
-
}
|
|
69
|
-
makeFrom(values) {
|
|
70
|
-
return ExtValueList.from(values, this);
|
|
71
|
-
}
|
|
72
|
-
static from(values, options) {
|
|
73
|
-
const list = new ExtValueList(null, options);
|
|
74
|
-
for (const value of values) {
|
|
75
|
-
list.addAfter(value);
|
|
76
|
-
list.next();
|
|
77
|
-
}
|
|
78
|
-
return list.next();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.ExtValueList = ExtValueList;
|
|
82
|
-
ExtValueList.Ptr = _ext.Ptr;
|
|
83
|
-
ExtValueList.ValueNode = _nodes.ValueNode;
|
|
84
|
-
(0, _metaUtils.addAliases)(ExtValueList.prototype, {
|
|
85
|
-
getValueIterator: 'getIterator',
|
|
86
|
-
getReverseValueIterator: 'getReverseIterator'
|
|
87
|
-
});
|
|
88
|
-
var _default = exports.default = ExtValueList;
|