orbit-db-eventstore
Advanced tools
Comparing version 1.4.0 to 1.5.0-rc.1
{ | ||
"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" | ||
} | ||
} |
'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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1274413
10
78
0
1
1
- Removedcore-util-is@1.0.3(transitive)
- Removedinherits@2.0.4(transitive)
- Removedipfs-log@4.2.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedlogplease@1.2.15(transitive)
- Removedorbit-db-store@2.5.4(transitive)
- Removedp-each-series@1.0.0(transitive)
- Removedp-map@1.2.0(transitive)
- Removedp-reduce@1.0.0(transitive)
- Removedp-whilst@1.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedorbit-db-store@rc1