@bablr/btree 0.4.3 → 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 -0
  2. package/package.json +1 -1
@@ -297,6 +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 (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)]);
300
314
  }
301
315
  }
302
316
 
@@ -320,6 +334,10 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
320
334
  }
321
335
  }
322
336
 
337
+ if (values.length === 1) {
338
+ values = getValues(values[0]);
339
+ }
340
+
323
341
  returnValue = node = setValues(node, values);
324
342
  }
325
343
  };
@@ -333,6 +351,7 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
333
351
  };
334
352
 
335
353
  const validateValues = (values) => {
354
+ if (isFinite(values[0])) throw new Error('oh my');
336
355
  if (values.length > NODE_SIZE) throw new Error();
337
356
  if (!values.length) return;
338
357
 
@@ -370,6 +389,7 @@ export const buildModule = (NODE_SIZE = defaultNodeSize, buildStats) => {
370
389
  };
371
390
 
372
391
  const setValues = (node, values) => {
392
+ if (isFinite(values[0])) throw new Error('oh my');
373
393
  if (isFinite(node[0]) || buildStats) {
374
394
  return treeFromValues(values);
375
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.3",
4
+ "version": "0.4.5",
5
5
  "author": "Conrad Buck<conartist6@gmail.com>",
6
6
  "type": "module",
7
7
  "files": [