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 1.4.0 to 1.5.0-rc.1

CODE_OF_CONDUCT.md

21

package.json
{
"name": "orbit-db-eventstore",
"version": "1.4.0",
"version": "1.5.0-rc.1",
"description": "Eventlog for orbit-db",
"main": "src/EventStore.js",
"homepage": "https://github.com/orbitdb/orbit-db-eventstore",
"bugs": "https://github.com/orbitdb/orbit-db-eventstore/issues",
"repository": {
"type": "git",
"url": "https://github.com/orbitdb/orbit-db-eventstore"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "standard"
},
"keywords": [
"orbitdb",
"orbit-db",
"eventstore"
],
"author": "Haad",
"license": "MIT",
"dependencies": {
"orbit-db-store": "~2.5.0"
"orbit-db-store": "rc1"
},
"devDependencies": {
"standard": "^12.0.1"
}
}

6

src/EventIndex.js
'use strict'
class EventIndex {
constructor() {
constructor () {
this._index = null
}
get() {
get () {
return this._index ? this._index.values : []
}
updateIndex(oplog) {
updateIndex (oplog) {
this._index = oplog

@@ -14,0 +14,0 @@ }

@@ -9,4 +9,4 @@ 'use strict'

class EventStore extends Store {
constructor(ipfs, id, dbname, options = {}) {
if(options.Index === undefined) Object.assign(options, { Index: EventIndex })
constructor (ipfs, id, dbname, options = {}) {
if (options.Index === undefined) Object.assign(options, { Index: EventIndex })
super(ipfs, id, dbname, options)

@@ -16,3 +16,3 @@ this._type = 'eventlog'

add(data) {
add (data) {
return this._addOperation({

@@ -25,18 +25,18 @@ op: 'ADD',

get(hash) {
get (hash) {
return this.iterator({ gte: hash, limit: 1 }).collect()[0]
}
iterator(options) {
iterator (options) {
const messages = this._query(options)
let currentIndex = 0
let iterator = {
[Symbol.iterator]() {
[Symbol.iterator] () {
return this
},
next() {
next () {
let item = { value: null, done: true }
if(currentIndex < messages.length) {
if (currentIndex < messages.length) {
item = { value: messages[currentIndex], done: false }
currentIndex ++
currentIndex++
}

@@ -51,4 +51,4 @@ return item

_query(opts) {
if(!opts) opts = {}
_query (opts) {
if (!opts) opts = {}

@@ -59,5 +59,5 @@ const amount = opts.limit ? (opts.limit > -1 ? opts.limit : this._index.get().length) : 1 // Return 1 if no limit is provided

if(opts.gt || opts.gte) {
if (opts.gt || opts.gte) {
// Greater than case
result = this._read(events, opts.gt ? opts.gt : opts.gte, amount, opts.gte ? true : false)
result = this._read(events, opts.gt ? opts.gt : opts.gte, amount, !!opts.gte)
} else {

@@ -71,3 +71,3 @@ // Lower than and lastN case, search latest first by reversing the sequence

_read(ops, hash, amount, inclusive) {
_read (ops, hash, amount, inclusive) {
// Find the index of the gt/lt hash, or start from the beginning of the array if not found

@@ -74,0 +74,0 @@ const index = ops.map((e) => e.hash).indexOf(hash)

Sorry, the diff of this file is not supported yet

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