@bablr/btree 0.4.4 → 0.4.5
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 +20 -9
- package/package.json +1 -1
package/lib/enhanceable.js
CHANGED
|
@@ -297,15 +297,20 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
|
|
|
297
297
|
values.splice(targetSibling === prevSibling ? values.length : 0, 0, donated);
|
|
298
298
|
|
|
299
299
|
returnValue = setValues(returnValue, values);
|
|
300
|
-
} else if (
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
300
|
+
} else if (prevSibling && getValues(prevSibling).length + values.length <= NODE_SIZE) {
|
|
301
|
+
adjustSibling = {
|
|
302
|
+
node: null,
|
|
303
|
+
index: parentIndex - 1,
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
returnValue = treeFromValues([...getValues(prevSibling), ...values]);
|
|
307
|
+
} else if (nextSibling && values.length + getValues(nextSibling).length <= NODE_SIZE) {
|
|
308
|
+
adjustSibling = {
|
|
309
|
+
node: null,
|
|
310
|
+
index: parentIndex + 1,
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
returnValue = treeFromValues([...values, ...getValues(nextSibling)]);
|
|
309
314
|
}
|
|
310
315
|
}
|
|
311
316
|
|
|
@@ -329,6 +334,10 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
|
|
|
329
334
|
}
|
|
330
335
|
}
|
|
331
336
|
|
|
337
|
+
if (values.length === 1) {
|
|
338
|
+
values = getValues(values[0]);
|
|
339
|
+
}
|
|
340
|
+
|
|
332
341
|
returnValue = node = setValues(node, values);
|
|
333
342
|
}
|
|
334
343
|
};
|
|
@@ -342,6 +351,7 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
|
|
|
342
351
|
};
|
|
343
352
|
|
|
344
353
|
const validateValues = (values) => {
|
|
354
|
+
if (isFinite(values[0])) throw new Error('oh my');
|
|
345
355
|
if (values.length > NODE_SIZE) throw new Error();
|
|
346
356
|
if (!values.length) return;
|
|
347
357
|
|
|
@@ -379,6 +389,7 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
|
|
|
379
389
|
};
|
|
380
390
|
|
|
381
391
|
const setValues = (node, values) => {
|
|
392
|
+
if (isFinite(values[0])) throw new Error('oh my');
|
|
382
393
|
if (isFinite(node[0]) || buildStats) {
|
|
383
394
|
return treeFromValues(values);
|
|
384
395
|
}
|
package/package.json
CHANGED