@graffy/common 0.15.15-alpha.1 → 0.15.16

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 (3) hide show
  1. package/index.cjs +6 -3
  2. package/index.mjs +6 -3
  3. package/package.json +3 -3
package/index.cjs CHANGED
@@ -271,7 +271,7 @@ function keyBefore(key) {
271
271
  return key.charCodeAt(l) === 0 ? key.substr(0, l) : key.substr(0, l) + String.fromCharCode(key.charCodeAt(l) - 1) + "\uFFFF";
272
272
  }
273
273
  function keyAfter(key) {
274
- if (key === "" || key === "\uFFFF" || key === "\0" || key === "\0\uFFFF") {
274
+ if (key === "\uFFFF" || key === "\0" || key === "\0\uFFFF") {
275
275
  return key;
276
276
  }
277
277
  const l = key.length - 1;
@@ -502,8 +502,11 @@ function add(base, diff) {
502
502
  }
503
503
  if (nodeIsBranch && itemIsBranch) {
504
504
  changed = add(item.children, node.children) || changed;
505
- } else if (nodeIsBranch || itemIsBranch) {
506
- throw new Error("add.branch_leaf_mismatch");
505
+ } else if (nodeIsBranch) {
506
+ continue;
507
+ } else if (itemIsBranch) {
508
+ item.value = node.value;
509
+ changed = true;
507
510
  } else {
508
511
  item.value += node.value;
509
512
  }
package/index.mjs CHANGED
@@ -263,7 +263,7 @@ function keyBefore(key) {
263
263
  return key.charCodeAt(l) === 0 ? key.substr(0, l) : key.substr(0, l) + String.fromCharCode(key.charCodeAt(l) - 1) + "\uFFFF";
264
264
  }
265
265
  function keyAfter(key) {
266
- if (key === "" || key === "\uFFFF" || key === "\0" || key === "\0\uFFFF") {
266
+ if (key === "\uFFFF" || key === "\0" || key === "\0\uFFFF") {
267
267
  return key;
268
268
  }
269
269
  const l = key.length - 1;
@@ -494,8 +494,11 @@ function add(base, diff) {
494
494
  }
495
495
  if (nodeIsBranch && itemIsBranch) {
496
496
  changed = add(item.children, node.children) || changed;
497
- } else if (nodeIsBranch || itemIsBranch) {
498
- throw new Error("add.branch_leaf_mismatch");
497
+ } else if (nodeIsBranch) {
498
+ continue;
499
+ } else if (itemIsBranch) {
500
+ item.value = node.value;
501
+ changed = true;
499
502
  } else {
500
503
  item.value += node.value;
501
504
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graffy/common",
3
3
  "description": "Common libraries that used by various Graffy modules.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.15.15-alpha.1",
5
+ "version": "0.15.16",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -17,8 +17,8 @@
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
19
  "lodash": "^4.17.19",
20
- "nanoid": "^3.1.25",
21
20
  "merge-async-iterators": "^0.2.1",
22
- "@graffy/stream": "0.15.15-alpha.1"
21
+ "@graffy/stream": "0.15.16",
22
+ "nanoid": "^3.1.31"
23
23
  }
24
24
  }