@bablr/btree 0.1.0 → 0.1.1
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 +18 -1
- package/lib/index.js +3 -1
- package/package.json +1 -1
package/lib/enhanceable.js
CHANGED
|
@@ -11,6 +11,22 @@ export const buildModule = (NODE_SIZE = 8) => {
|
|
|
11
11
|
|
|
12
12
|
const treeFrom = (...trees) => [sumNodes(trees), trees];
|
|
13
13
|
|
|
14
|
+
const from = (...values) => {
|
|
15
|
+
let tree = [];
|
|
16
|
+
for (const value of values) {
|
|
17
|
+
tree = push(tree, value);
|
|
18
|
+
}
|
|
19
|
+
return tree;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const fromValues = (values) => {
|
|
23
|
+
let tree = [];
|
|
24
|
+
for (const value of values) {
|
|
25
|
+
tree = push(tree, value);
|
|
26
|
+
}
|
|
27
|
+
return tree;
|
|
28
|
+
};
|
|
29
|
+
|
|
14
30
|
const findBalancePoint = (tree) => {
|
|
15
31
|
const values = isFinite(tree[0]) ? tree[1] : tree;
|
|
16
32
|
let leftSum = 0;
|
|
@@ -375,7 +391,8 @@ export const buildModule = (NODE_SIZE = 8) => {
|
|
|
375
391
|
|
|
376
392
|
return {
|
|
377
393
|
buildModule,
|
|
378
|
-
|
|
394
|
+
from,
|
|
395
|
+
fromValues,
|
|
379
396
|
findBalancePoint,
|
|
380
397
|
split,
|
|
381
398
|
collapses,
|
package/lib/index.js
CHANGED
package/package.json
CHANGED