prefix-hash-tree 0.0.6 → 0.0.7
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/index.js +1 -2
- package/lib/pht-node.d.ts +1 -2
- package/lib/pht-node.js +5 -7
- package/package.json +1 -1
package/index.js
CHANGED
package/lib/pht-node.d.ts
CHANGED
package/lib/pht-node.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
function createPHTNode({ label,
|
|
1
|
+
function createPHTNode({ label, isLeaf, lPtr, rPtr, keys } = {}) {
|
|
2
2
|
return {
|
|
3
3
|
label: label || '',
|
|
4
|
-
|
|
5
|
-
child1: child1 || null,
|
|
4
|
+
isLeaf: isLeaf !== undefined ? isLeaf : true,
|
|
6
5
|
lPtr: lPtr || null,
|
|
7
6
|
rPtr: rPtr || null,
|
|
8
7
|
keys: keys || {}
|
|
@@ -12,7 +11,7 @@ function createPHTNode({ label, child0, child1, lPtr, rPtr, keys } = {}) {
|
|
|
12
11
|
function isNode(obj) {
|
|
13
12
|
if (typeof obj !== 'object' || obj === null) return false
|
|
14
13
|
|
|
15
|
-
const validKeys = new Set(['label', '
|
|
14
|
+
const validKeys = new Set(['label', 'isLeaf', 'lPtr', 'rPtr', 'keys'])
|
|
16
15
|
|
|
17
16
|
const keys = Object.keys(obj)
|
|
18
17
|
|
|
@@ -21,8 +20,7 @@ function isNode(obj) {
|
|
|
21
20
|
|
|
22
21
|
return (
|
|
23
22
|
isBinaryString(obj.label) &&
|
|
24
|
-
|
|
25
|
-
isBinaryStringOrNull(obj.child1) &&
|
|
23
|
+
typeof obj.isLeaf === 'boolean' &&
|
|
26
24
|
isBinaryStringOrNull(obj.lPtr) &&
|
|
27
25
|
isBinaryStringOrNull(obj.rPtr) &&
|
|
28
26
|
typeof obj.keys === 'object' &&
|
|
@@ -46,7 +44,7 @@ function isBinaryStringOrNull(v) {
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
function isLeaf(node) {
|
|
49
|
-
return node.
|
|
47
|
+
return node.isLeaf
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
function get(node, key) {
|