@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.
@@ -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
@@ -16,6 +16,8 @@ export const {
16
16
  push,
17
17
  concat,
18
18
  addAt,
19
+ shift,
20
+ unshift,
19
21
  isValidNode,
20
22
  assertValidNode,
21
23
  getValues,
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.2",
4
+ "version": "0.4.3",
5
5
  "author": "Conrad Buck<conartist6@gmail.com>",
6
6
  "type": "module",
7
7
  "files": [