hypercore 11.16.2 → 11.17.0

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.
@@ -1,11 +1,11 @@
1
1
  const TICKS = 16
2
2
 
3
3
  module.exports = class HotswapQueue {
4
- constructor () {
4
+ constructor() {
5
5
  this.priorities = [[], [], []]
6
6
  }
7
7
 
8
- * pick (peer) {
8
+ *pick(peer) {
9
9
  for (let i = 0; i < this.priorities.length; i++) {
10
10
  // try first one more than second one etc etc
11
11
  let ticks = (this.priorities.length - i) * TICKS
@@ -30,7 +30,7 @@ module.exports = class HotswapQueue {
30
30
  }
31
31
  }
32
32
 
33
- add (block) {
33
+ add(block) {
34
34
  if (block.hotswap !== null) this.remove(block)
35
35
  if (block.inflight.length === 0 || block.inflight.length >= 3) return
36
36
 
@@ -41,7 +41,7 @@ module.exports = class HotswapQueue {
41
41
  block.hotswap = { ref: this, queue, index }
42
42
  }
43
43
 
44
- remove (block) {
44
+ remove(block) {
45
45
  const hotswap = block.hotswap
46
46
  if (hotswap === null) return
47
47
 
@@ -52,7 +52,7 @@ module.exports = class HotswapQueue {
52
52
  }
53
53
  }
54
54
 
55
- function hasInflight (block, peer) {
55
+ function hasInflight(block, peer) {
56
56
  for (let j = 0; j < block.inflight.length; j++) {
57
57
  if (block.inflight[j].peer === peer) return true
58
58
  }
package/lib/info.js CHANGED
@@ -1,5 +1,5 @@
1
1
  module.exports = class Info {
2
- constructor (opts = {}) {
2
+ constructor(opts = {}) {
3
3
  this.key = opts.key
4
4
  this.discoveryKey = opts.discoveryKey
5
5
  this.length = opts.length || 0
@@ -10,7 +10,7 @@ module.exports = class Info {
10
10
  this.storage = opts.storage || null
11
11
  }
12
12
 
13
- static async from (session, opts = {}) {
13
+ static async from(session, opts = {}) {
14
14
  return new Info({
15
15
  key: session.key,
16
16
  discoveryKey: session.discoveryKey,
@@ -23,7 +23,7 @@ module.exports = class Info {
23
23
  })
24
24
  }
25
25
 
26
- static async storage (session) {
26
+ static async storage(session) {
27
27
  const { oplog, tree, blocks, bitfield } = session.core
28
28
  try {
29
29
  return {
@@ -37,7 +37,7 @@ module.exports = class Info {
37
37
  }
38
38
  }
39
39
 
40
- static bytesUsed (file) {
40
+ static bytesUsed(file) {
41
41
  return new Promise((resolve, reject) => {
42
42
  file.stat((err, st) => {
43
43
  if (err) {