orbit-db-eventstore
Advanced tools
Comparing version 0.1.9 to 0.2.0
{ | ||
"name": "orbit-db-eventstore", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "Eventlog for orbit-db", | ||
@@ -12,7 +12,4 @@ "main": "src/EventStore.js", | ||
"dependencies": { | ||
"lodash.findindex": "^4.6.0", | ||
"lodash.slice": "^4.2.0", | ||
"lodash.take": "^4.1.1", | ||
"orbit-db-store": "^0.1.10" | ||
"orbit-db-store": "~0.2.0" | ||
} | ||
} |
@@ -5,18 +5,11 @@ 'use strict' | ||
constructor() { | ||
this._index = {} | ||
this._index = [] | ||
} | ||
get() { | ||
return Object.keys(this._index).map((f) => this._index[f]) | ||
return this._index | ||
} | ||
updateIndex(oplog, added) { | ||
added.reduce((handled, item) => { | ||
if(!handled.includes(item.hash)) { | ||
handled.push(item.hash) | ||
if(item.payload.op === 'ADD') | ||
this._index[item.hash] = item | ||
} | ||
return handled | ||
}, []) | ||
updateIndex(oplog) { | ||
this._index = oplog.items | ||
} | ||
@@ -23,0 +16,0 @@ } |
'use strict' | ||
const slice = require('lodash.slice') | ||
const take = require('lodash.take') | ||
const findIndex = require('lodash.findindex') | ||
const Store = require('orbit-db-store') | ||
const EventIndex = require('./EventIndex') | ||
// TODO: generalize the Iterator functions and spin to its own module | ||
class EventStore extends Store { | ||
@@ -19,6 +18,3 @@ constructor(ipfs, id, dbname, options = {}) { | ||
key: null, | ||
value: data, | ||
meta: { | ||
ts: new Date().getTime() | ||
} | ||
value: data | ||
}) | ||
@@ -56,3 +52,3 @@ } | ||
const amount = opts.limit ? (opts.limit > -1 ? opts.limit : this._index.get().length) : 1 // Return 1 if no limit is provided | ||
const events = this._index.get() | ||
const events = this._index.get().slice() | ||
let result = [] | ||
@@ -73,7 +69,9 @@ | ||
// Find the index of the gt/lt hash, or start from the beginning of the array if not found | ||
let startIndex = Math.max(findIndex(ops, (e) => e.hash === hash), 0) | ||
const index = ops.map((e) => e.hash).indexOf(hash) | ||
let startIndex = Math.max(index, 0) | ||
// If gte/lte is set, we include the given hash, if not, start from the next element | ||
startIndex += (inclusive ? 0 : 1) | ||
startIndex += inclusive ? 0 : 1 | ||
// Slice the array to its requested size | ||
return take(ops.slice(startIndex), amount) | ||
const res = ops.slice(startIndex).slice(0, amount) | ||
return res | ||
} | ||
@@ -80,0 +78,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1
0
1269571
4884
+ Addeddexie@1.5.1(transitive)
+ Addedfs-pull-blob-store@0.4.1(transitive)
+ Addedidb-pull-blob-store@0.5.1(transitive)
+ Addedipfs-log@2.0.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedlock@0.1.4(transitive)
+ Addedlooper@2.0.04.0.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedorbit-db-cache@0.0.7(transitive)
+ Addedorbit-db-store@0.2.3(transitive)
+ Addedp-map@1.0.0(transitive)
+ Addedp-whilst@1.0.0(transitive)
+ Addedpull-cat@1.1.11(transitive)
+ Addedpull-defer@0.2.3(transitive)
+ Addedpull-file@1.1.0(transitive)
+ Addedpull-pushable@2.2.0(transitive)
+ Addedpull-stream@3.6.14(transitive)
+ Addedpull-utf8-decoder@1.0.2(transitive)
+ Addedpull-window@2.1.4(transitive)
+ Addedpull-write@1.1.4(transitive)
+ Addedpull-write-file@0.2.4(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)
- Removedlodash.findindex@^4.6.0
- Removedlodash.slice@^4.2.0
- Removedlodash.take@^4.1.1
- Removedbluebird@3.7.2(transitive)
- Removedipfs-log@1.6.0-beta.8(transitive)
- Removedlodash.differencewith@4.5.0(transitive)
- Removedlodash.findindex@4.6.0(transitive)
- Removedlodash.flatten@4.4.0(transitive)
- Removedlodash.slice@4.2.0(transitive)
- Removedlodash.take@4.1.1(transitive)
- Removedlodash.unionwith@4.6.0(transitive)
- Removedorbit-db-store@0.1.16(transitive)
Updatedorbit-db-store@~0.2.0