Skip to content

Commit c72bbc3

Browse files
committed
Clean up code formatting
1 parent 7797b0d commit c72bbc3

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/DocumentIndex.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
'use strict'
22

33
class DocumentIndex {
4-
constructor() {
4+
constructor () {
55
this._index = {}
66
}
77

8-
get(key, fullOp = false) {
8+
get (key, fullOp = false) {
99
return fullOp
1010
? this._index[key]
1111
: this._index[key].payload.value
1212
}
1313

14-
updateIndex(oplog, onProgressCallback) {
14+
updateIndex (oplog, onProgressCallback) {
1515
const reducer = (handled, item, idx) => {
16-
// if (handled.indexOf(item.payload.key) === -1) {
1716
if (handled[item.payload.key] !== true) {
18-
// handled.push(item.payload.key)
1917
handled[item.payload.key] = true
2018
if(item.payload.op === 'PUT') {
2119
this._index[item.payload.key] = item

src/DocumentStore.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const Readable = require('readable-stream')
88
const replaceAll = (str, search, replacement) => str.toString().split(search).join(replacement)
99

1010
class DocumentStore extends Store {
11-
constructor(ipfs, id, dbname, options) {
11+
constructor (ipfs, id, dbname, options) {
1212
if (!options) options = {}
1313
if (!options.indexBy) Object.assign(options, { indexBy: '_id' })
1414
if (!options.Index) Object.assign(options, { Index: DocumentIndex })
1515
super(ipfs, id, dbname, options)
1616
this._type = 'docstore'
1717
}
1818

19-
get(key, caseSensitive = false) {
19+
get (key, caseSensitive = false) {
2020
key = key.toString()
2121
const terms = key.split(' ')
2222
key = terms.length > 1 ? replaceAll(key, '.', ' ').toLowerCase() : key.toLowerCase()
@@ -37,16 +37,16 @@ class DocumentStore extends Store {
3737
.map(mapper)
3838
}
3939

40-
query(mapper, options = {}) {
40+
query (mapper, options = {}) {
4141
// Whether we return the full operation data or just the db value
4242
const fullOp = options ? options.fullOp : false
4343

4444
return Object.keys(this._index._index)
4545
.map((e) => this._index.get(e, fullOp))
46-
.filter((e) => mapper(e))
46+
.filter(mapper)
4747
}
4848

49-
batchPut(docs, onProgressCallback) {
49+
batchPut (docs, onProgressCallback) {
5050
const mapper = (doc, idx) => {
5151
return this._addOperationBatch(
5252
{
@@ -64,7 +64,7 @@ class DocumentStore extends Store {
6464
.then(() => this.saveSnapshot())
6565
}
6666

67-
put(doc) {
67+
put (doc) {
6868
if (!doc[this.options.indexBy])
6969
throw new Error(`The provided document doesn't contain field '${this.options.indexBy}'`)
7070

@@ -75,7 +75,7 @@ class DocumentStore extends Store {
7575
})
7676
}
7777

78-
del(key) {
78+
del (key) {
7979
if (!this._index.get(key))
8080
throw new Error(`No entry with key '${key}' in the database`)
8181

0 commit comments

Comments
 (0)