prefix-hash-tree 0.0.7 → 0.0.8

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 CHANGED
@@ -1,17 +1,6 @@
1
1
  const sodium = require('sodium-universal')
2
2
  const b4a = require('b4a')
3
- const {
4
- createPHTNode,
5
- isLeaf,
6
- get,
7
- getAll,
8
- set,
9
- label,
10
- size,
11
- setPointers,
12
- pointerLeft,
13
- pointerRight
14
- } = require('./lib/pht-node.js')
3
+ const { createPHTNode, isLeaf, get, getAll, set, label, size } = require('./lib/pht-node.js')
15
4
 
16
5
  class PrefixHashTree {
17
6
  constructor(opts = {}) {
@@ -132,9 +121,6 @@ class PrefixHashTree {
132
121
  const child0 = createPHTNode({ label: `${label(leaf)}0` })
133
122
  const child1 = createPHTNode({ label: `${label(leaf)}1` })
134
123
 
135
- setPointers(child0, pointerLeft(leaf), label(child1))
136
- setPointers(child1, label(child0), pointerRight(leaf))
137
-
138
124
  const parent = createPHTNode({
139
125
  label: label(leaf),
140
126
  isLeaf: false
package/lib/pht-node.d.ts CHANGED
@@ -2,8 +2,6 @@ declare module 'prefix-hash-tree' {
2
2
  export interface PHTNode {
3
3
  label: string
4
4
  isLeaf: boolean
5
- lPtr: string | null
6
- rPtr: string | null
7
5
  keys: Record<string, any>
8
6
  }
9
7
 
@@ -20,10 +18,4 @@ declare module 'prefix-hash-tree' {
20
18
  export function label(node: PHTNode): string
21
19
 
22
20
  export function size(node: PHTNode): number
23
-
24
- export function setPointers(node: PHTNode, left: string | null, right: string | null): void
25
-
26
- export function pointerLeft(node: PHTNode): string | null
27
-
28
- export function pointerRight(node: PHTNode): string | null
29
21
  }
package/lib/pht-node.js CHANGED
@@ -1,9 +1,7 @@
1
- function createPHTNode({ label, isLeaf, lPtr, rPtr, keys } = {}) {
1
+ function createPHTNode({ label, isLeaf, keys } = {}) {
2
2
  return {
3
3
  label: label || '',
4
4
  isLeaf: isLeaf !== undefined ? isLeaf : true,
5
- lPtr: lPtr || null,
6
- rPtr: rPtr || null,
7
5
  keys: keys || {}
8
6
  }
9
7
  }
@@ -11,7 +9,7 @@ function createPHTNode({ label, isLeaf, lPtr, rPtr, keys } = {}) {
11
9
  function isNode(obj) {
12
10
  if (typeof obj !== 'object' || obj === null) return false
13
11
 
14
- const validKeys = new Set(['label', 'isLeaf', 'lPtr', 'rPtr', 'keys'])
12
+ const validKeys = new Set(['label', 'isLeaf', 'keys'])
15
13
 
16
14
  const keys = Object.keys(obj)
17
15
 
@@ -21,8 +19,6 @@ function isNode(obj) {
21
19
  return (
22
20
  isBinaryString(obj.label) &&
23
21
  typeof obj.isLeaf === 'boolean' &&
24
- isBinaryStringOrNull(obj.lPtr) &&
25
- isBinaryStringOrNull(obj.rPtr) &&
26
22
  typeof obj.keys === 'object' &&
27
23
  obj.keys !== null &&
28
24
  !Array.isArray(obj.keys)
@@ -39,10 +35,6 @@ function isBinaryString(s) {
39
35
  return true
40
36
  }
41
37
 
42
- function isBinaryStringOrNull(v) {
43
- return v === null || isBinaryString(v)
44
- }
45
-
46
38
  function isLeaf(node) {
47
39
  return node.isLeaf
48
40
  }
@@ -67,19 +59,6 @@ function size(node) {
67
59
  return Object.keys(node.keys).length
68
60
  }
69
61
 
70
- function setPointers(node, left, right) {
71
- node.lPtr = left
72
- node.rPtr = right
73
- }
74
-
75
- function pointerLeft(node) {
76
- return node.lPtr
77
- }
78
-
79
- function pointerRight(node) {
80
- return node.rPtr
81
- }
82
-
83
62
  module.exports = {
84
63
  createPHTNode,
85
64
  isNode,
@@ -88,8 +67,5 @@ module.exports = {
88
67
  getAll,
89
68
  set,
90
69
  label,
91
- size,
92
- setPointers,
93
- pointerLeft,
94
- pointerRight
70
+ size
95
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prefix-hash-tree",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "An extensible prefix hash tree for indexing over distributed hash tables",
5
5
  "main": "index.js",
6
6
  "exports": {