@bablr/btree 0.4.2 → 0.4.3
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/lib/enhanceable.js +11 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/lib/enhanceable.js
CHANGED
|
@@ -235,6 +235,10 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
|
|
|
235
235
|
return size ? addAt(size, tree, value) : treeFromValues([value]);
|
|
236
236
|
};
|
|
237
237
|
|
|
238
|
+
const unshift = (value, tree) => {
|
|
239
|
+
return addAt(0, tree, value);
|
|
240
|
+
};
|
|
241
|
+
|
|
238
242
|
const collapses = (size) => {
|
|
239
243
|
return size < NODE_SIZE / 2 - 0.01;
|
|
240
244
|
};
|
|
@@ -324,6 +328,10 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
|
|
|
324
328
|
return removeAt(-1, tree);
|
|
325
329
|
};
|
|
326
330
|
|
|
331
|
+
const shift = (tree) => {
|
|
332
|
+
return removeAt(0, tree);
|
|
333
|
+
};
|
|
334
|
+
|
|
327
335
|
const validateValues = (values) => {
|
|
328
336
|
if (values.length > NODE_SIZE) throw new Error();
|
|
329
337
|
if (!values.length) return;
|
|
@@ -546,10 +554,13 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
|
|
|
546
554
|
collapses,
|
|
547
555
|
nodeCollapses,
|
|
548
556
|
nodeCanDonate,
|
|
557
|
+
unshift,
|
|
549
558
|
pop,
|
|
550
559
|
removeAt,
|
|
551
560
|
push,
|
|
552
561
|
addAt,
|
|
562
|
+
shift,
|
|
563
|
+
unshift,
|
|
553
564
|
concat,
|
|
554
565
|
isValidNode,
|
|
555
566
|
assertValidNode,
|
package/lib/index.js
CHANGED
package/package.json
CHANGED