@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.
Files changed (2) hide show
  1. package/lib/enhanceable.js +20 -9
  2. package/package.json +1 -1
@@ -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
- getValues(prevSibling).length + values.length + getValues(nextSibling).length <=
302
- NODE_SIZE
303
- ) {
304
- returnValue = treeFromValues([
305
- ...getValues(prevSibling),
306
- ...values,
307
- ...getValues(nextSibling),
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bablr/btree",
3
3
  "description": "Functional utilities for working with btrees such as those used in agAST",
4
- "version": "0.4.4",
4
+ "version": "0.4.5",
5
5
  "author": "Conrad Buck<conartist6@gmail.com>",
6
6
  "type": "module",
7
7
  "files": [