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

Commit 7adb894

Browse files
committed
3.3.0
1 parent 5686a3d commit 7adb894

File tree

4 files changed

+83
-82
lines changed

4 files changed

+83
-82
lines changed

dist/orbit-db-store.min.js

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

package-lock.json

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

src/Store.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ class Store {
133133
} catch (e) {
134134
console.error('Store Error:', e)
135135
}
136-
this.events.on("replicated.progress", (address, hash, entry, progress, have) => {
137-
this._procEntry(entry);
138-
});
139-
this.events.on("write", (address, entry, heads) => {
140-
this._procEntry(entry);
141-
});
136+
this.events.on('replicated.progress', (address, hash, entry, progress, have) => {
137+
this._procEntry(entry)
138+
})
139+
this.events.on('write', (address, entry, heads) => {
140+
this._procEntry(entry)
141+
})
142142
}
143143

144144
get all () {
@@ -194,8 +194,8 @@ class Store {
194194
}
195195

196196
// Remove all event listeners
197-
for(var event in this.events._events) {
198-
this.events.removeAllListeners(event);
197+
for (var event in this.events._events) {
198+
this.events.removeAllListeners(event)
199199
}
200200

201201
// Database is now closed
@@ -529,14 +529,14 @@ class Store {
529529
_addOperationBatch (data, batchOperation, lastOperation, onProgressCallback) {
530530
throw new Error('Not implemented!')
531531
}
532-
533-
_procEntry(entry) {
534-
var { payload, hash } = entry;
535-
var { op } = payload;
536-
if(op) {
537-
this.events.emit(`log.op.${op}`, this.address.toString(), hash, payload);
532+
533+
_procEntry (entry) {
534+
var { payload, hash } = entry
535+
var { op } = payload
536+
if (op) {
537+
this.events.emit(`log.op.${op}`, this.address.toString(), hash, payload)
538538
} else {
539-
this.events.emit(`log.op.none`, this.address.toString(), hash, payload);
539+
this.events.emit('log.op.none', this.address.toString(), hash, payload)
540540
}
541541
this.events.emit('log.op', op, this.address.toString(), hash, payload)
542542
}

test/events.spec.js

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,68 @@ const DefaultOptions = Store.DefaultOptions
1010

1111
// Test utils
1212
const {
13-
config,
14-
testAPIs,
15-
startIpfs,
16-
stopIpfs,
17-
implementations
13+
config,
14+
testAPIs,
15+
startIpfs,
16+
stopIpfs,
17+
implementations
1818
} = require('orbit-db-test-utils')
1919

2020
const properLevelModule = implementations.filter(i => i.key.indexOf('memdown') > -1).map(i => i.module)[0]
2121
const storage = require('orbit-db-storage-adapter')(properLevelModule)
2222

2323
Object.keys(testAPIs).forEach((IPFS) => {
24-
describe(`Events ${IPFS}`, function () {
25-
let ipfs, testIdentity, identityStore, store, cacheStore
24+
describe(`Events ${IPFS}`, function () {
25+
let ipfsd, ipfs, testIdentity, identityStore, store, cacheStore
2626

27-
this.timeout(config.timeout)
27+
this.timeout(config.timeout)
2828

29-
const ipfsConfig = Object.assign({}, config.defaultIpfsConfig, {
30-
repo: config.defaultIpfsConfig.repo + '-entry' + new Date().getTime()
31-
})
32-
after(async () => {
33-
await store.close()
34-
await stopIpfs(ipfs)
35-
await identityStore.close()
36-
await cacheStore.close()
37-
})
29+
const ipfsConfig = Object.assign({}, config.defaultIpfsConfig, {
30+
repo: config.defaultIpfsConfig.repo + '-entry' + new Date().getTime()
31+
})
32+
after(async () => {
33+
await store.close()
34+
await stopIpfs(ipfsd)
35+
await identityStore.close()
36+
await cacheStore.close()
37+
})
3838

39-
afterEach(async () => {
40-
await store.drop()
41-
await cacheStore.open()
42-
await identityStore.open()
43-
})
44-
before(async () => {
45-
identityStore = await storage.createStore('identity')
46-
const keystore = new Keystore(identityStore)
39+
afterEach(async () => {
40+
await store.drop()
41+
await cacheStore.open()
42+
await identityStore.open()
43+
})
4744

48-
cacheStore = await storage.createStore('cache')
49-
const cache = new Cache(cacheStore)
45+
before(async () => {
46+
identityStore = await storage.createStore('identity')
47+
const keystore = new Keystore(identityStore)
5048

51-
testIdentity = await IdentityProvider.createIdentity({ id: 'userA', keystore })
52-
ipfs = await startIpfs(IPFS, ipfsConfig)
49+
cacheStore = await storage.createStore('cache')
50+
const cache = new Cache(cacheStore)
5351

54-
const address = 'test-address'
55-
const options = Object.assign({}, DefaultOptions, { cache })
56-
store = new Store(ipfs, testIdentity, address, options)
57-
})
58-
it('Specific log.op event', (done) => {
59-
var data = {
60-
op: "SET",
61-
key: "transaction",
62-
value: "data"
63-
}
64-
store.events.on("log.op.SET", (id, address, payload) => {
65-
var {op, key, value} = payload;
66-
assert.strictEqual(op, data.op);
67-
assert.strictEqual(key, data.key);
68-
assert.strictEqual(value, data.value);
69-
assert.strictEqual(id, 'test-address');
70-
done();
71-
})
72-
store._addOperation(data)
73-
74-
})
52+
testIdentity = await IdentityProvider.createIdentity({ id: 'userA', keystore })
53+
ipfsd = await startIpfs(IPFS, ipfsConfig)
54+
ipfs = ipfsd.api
55+
56+
const address = 'test-address'
57+
const options = Object.assign({}, DefaultOptions, { cache })
58+
store = new Store(ipfs, testIdentity, address, options)
59+
})
60+
it('Specific log.op event', (done) => {
61+
var data = {
62+
op: 'SET',
63+
key: 'transaction',
64+
value: 'data'
65+
}
66+
store.events.on('log.op.SET', (id, address, payload) => {
67+
var { op, key, value } = payload
68+
assert.strictEqual(op, data.op)
69+
assert.strictEqual(key, data.key)
70+
assert.strictEqual(value, data.value)
71+
assert.strictEqual(id, 'test-address')
72+
done()
73+
})
74+
store._addOperation(data)
7575
})
76-
})
76+
})
77+
})

0 commit comments

Comments
 (0)