Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

orbit-db-eventstore

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orbit-db-eventstore - npm Package Compare versions

Comparing version 0.1.9 to 0.2.0

7

package.json
{
"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 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc