Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Commit 890af32

Browse files
committed
chore: standard --fix
1 parent 9a5993c commit 890af32

File tree

9 files changed

+578
-534
lines changed

9 files changed

+578
-534
lines changed

package-lock.json

Lines changed: 542 additions & 498 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"orbit-db-storage-adapter": "^0.5.3",
5252
"orbit-db-test-utils": "~0.12.1",
5353
"rimraf": "~3.0.2",
54-
"standard": "~14.3.4",
54+
"standard": "~16.0.3",
5555
"webpack": "~4.44.2",
5656
"webpack-cli": "~3.3.12",
5757
"yargs": "^16.1.1"

src/entry-io.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ class EntryIO {
8383
// not get stuck loading a block that is unreachable
8484
const timer = timeout && timeout > 0
8585
? setTimeout(() => {
86-
console.warn(`Warning: Couldn't fetch entry '${hash}', request timed out (${timeout}ms)`)
87-
resolve()
88-
}, timeout)
86+
console.warn(`Warning: Couldn't fetch entry '${hash}', request timed out (${timeout}ms)`)
87+
resolve()
88+
}, timeout)
8989
: null
9090

9191
const addToResults = (entry) => {

src/entry.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Entry {
172172
* @returns {number} 1 if a is greater, -1 is b is greater
173173
*/
174174
static compare (a, b) {
175-
var distance = Clock.compare(a.clock, b.clock)
175+
const distance = Clock.compare(a.clock, b.clock)
176176
if (distance === 0) return a.clock.id < b.clock.id ? -1 : 1
177177
return distance
178178
}
@@ -205,9 +205,9 @@ class Entry {
205205
* @returns {Array<Entry>}
206206
*/
207207
static findChildren (entry, values) {
208-
var stack = []
209-
var parent = values.find((e) => Entry.isParent(entry, e))
210-
var prev = entry
208+
let stack = []
209+
let parent = values.find((e) => Entry.isParent(entry, e))
210+
let prev = entry
211211
while (parent) {
212212
stack.push(parent)
213213
prev = parent

src/lamport-clock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LamportClock {
2121

2222
static compare (a, b) {
2323
// Calculate the "distance" based on the clock, ie. lower or greater
24-
var dist = a.time - b.time
24+
const dist = a.time - b.time
2525

2626
// If the sequence number is the same (concurrent events),
2727
// and the IDs are different, take the one with a "lower" id

src/log-io.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class LogIO {
149149
const missingSourceEntries = difference(sliced, sourceEntries, 'hash')
150150

151151
const replaceInFront = (a, withEntries) => {
152-
var sliced = a.slice(withEntries.length, a.length)
152+
const sliced = a.slice(withEntries.length, a.length)
153153
return withEntries.concat(sliced)
154154
}
155155

src/log.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -629,16 +629,16 @@ class Log extends GSet {
629629
* @returns {Array<Entry>}
630630
*/
631631
static findHeads (entries) {
632-
var indexReducer = (res, entry, idx, arr) => {
633-
var addToResult = e => (res[e] = entry.hash)
632+
const indexReducer = (res, entry, idx, arr) => {
633+
const addToResult = e => (res[e] = entry.hash)
634634
entry.next.forEach(addToResult)
635635
return res
636636
}
637637

638-
var items = entries.reduce(indexReducer, {})
638+
const items = entries.reduce(indexReducer, {})
639639

640-
var exists = e => items[e.hash] === undefined
641-
var compareIds = (a, b) => a.clock.id > b.clock.id
640+
const exists = e => items[e.hash] === undefined
641+
const compareIds = (a, b) => a.clock.id > b.clock.id
642642

643643
return entries.filter(exists).sort(compareIds)
644644
}
@@ -647,19 +647,19 @@ class Log extends GSet {
647647
// input array
648648
static findTails (entries) {
649649
// Reverse index { next -> entry }
650-
var reverseIndex = {}
650+
const reverseIndex = {}
651651
// Null index containing entries that have no parents (nexts)
652-
var nullIndex = []
652+
const nullIndex = []
653653
// Hashes for all entries for quick lookups
654-
var hashes = {}
654+
const hashes = {}
655655
// Hashes of all next entries
656-
var nexts = []
656+
let nexts = []
657657

658-
var addToIndex = (e) => {
658+
const addToIndex = (e) => {
659659
if (e.next.length === 0) {
660660
nullIndex.push(e)
661661
}
662-
var addToReverseIndex = (a) => {
662+
const addToReverseIndex = (a) => {
663663
/* istanbul ignore else */
664664
if (!reverseIndex[a]) reverseIndex[a] = []
665665
reverseIndex[a].push(e)
@@ -676,9 +676,9 @@ class Log extends GSet {
676676
// Create our indices
677677
entries.forEach(addToIndex)
678678

679-
var addUniques = (res, entries, idx, arr) => res.concat(findUniques(entries, 'hash'))
680-
var exists = e => hashes[e] === undefined
681-
var findFromReverseIndex = e => reverseIndex[e]
679+
const addUniques = (res, entries, idx, arr) => res.concat(findUniques(entries, 'hash'))
680+
const exists = e => hashes[e] === undefined
681+
const findFromReverseIndex = e => reverseIndex[e]
682682

683683
// Drop hashes that are not in the input entries
684684
const tails = nexts // For every hash in nexts:
@@ -693,10 +693,10 @@ class Log extends GSet {
693693
// Find the hashes to entries that are not in a collection
694694
// but referenced by other entries
695695
static findTailHashes (entries) {
696-
var hashes = {}
697-
var addToIndex = e => (hashes[e.hash] = true)
698-
var reduceTailHashes = (res, entry, idx, arr) => {
699-
var addToResult = (e) => {
696+
const hashes = {}
697+
const addToIndex = e => (hashes[e.hash] = true)
698+
const reduceTailHashes = (res, entry, idx, arr) => {
699+
const addToResult = (e) => {
700700
/* istanbul ignore else */
701701
if (hashes[e] === undefined) {
702702
res.splice(0, 0, e)

src/utils/difference.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
function difference (a, b, key) {
44
// Indices for quick lookups
5-
var processed = {}
6-
var existing = {}
5+
const processed = {}
6+
const existing = {}
77

88
// Create an index of the first collection
9-
var addToIndex = e => (existing[key ? e[key] : e] = true)
9+
const addToIndex = e => (existing[key ? e[key] : e] = true)
1010
a.forEach(addToIndex)
1111

1212
// Reduce to entries that are not in the first collection
13-
var reducer = (res, entry) => {
14-
var isInFirst = existing[key ? entry[key] : entry] !== undefined
15-
var hasBeenProcessed = processed[key ? entry[key] : entry] !== undefined
13+
const reducer = (res, entry) => {
14+
const isInFirst = existing[key ? entry[key] : entry] !== undefined
15+
const hasBeenProcessed = processed[key ? entry[key] : entry] !== undefined
1616
if (!isInFirst && !hasBeenProcessed) {
1717
res.push(entry)
1818
processed[key ? entry[key] : entry] = true

src/utils/find-uniques.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
function findUniques (value, key) {
44
// Create an index of the collection
55
const uniques = {}
6-
var get = e => uniques[e]
7-
var addToIndex = e => (uniques[key ? e[key] : e] = e)
6+
const get = e => uniques[e]
7+
const addToIndex = e => (uniques[key ? e[key] : e] = e)
88
value.forEach(addToIndex)
99
return Object.keys(uniques).map(get)
1010
}

0 commit comments

Comments
 (0)