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

orbit-db-storage-adapter

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orbit-db-storage-adapter - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

2

package.json
{
"name": "orbit-db-storage-adapter",
"version": "0.4.1",
"version": "0.4.2",
"description": "OrbitDB adapter for any abstract-leveldown compliant storage",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -18,31 +18,36 @@ 'use strict'

class Storage {
constructor (storage, options = {
createIfMissing: true,
errorIfExists: false,
compression: true,
cacheSize: 8 * 1024 * 1024 }
) {
constructor (storage, options = {}) {
const defaults = {
createIfMissing: true,
errorIfExists: false,
compression: true,
cacheSize: 8 * 1024 * 1024,
}
this.storage = storage
this.options = { down: options }
this.preCreate = options.preCreate ? options.preCreate : () => {}
const leveldownOptions = Object.assign({}, options, defaults)
delete leveldownOptions.preCreate
this.options = { down: leveldownOptions }
}
createStore (directory = './orbitdb', options = {}) {
return new Promise((resolve, reject) => {
return new Promise(async (resolve, reject) => {
this.options.up = options
this.preCreate(directory, this.options).then(() => {
const db = this.storage(directory, this.options.down)
await this.preCreate(directory, this.options)
const db = this.storage(directory, this.options.down)
// For compatibility with older abstract-leveldown stores
if (!db.status) db.status = 'unknown-shim'
if (!db.location) db.location = directory
// For compatibility with older abstract-leveldown stores
if (!db.status) db.status = 'unknown-shim'
if (!db.location) db.location = directory
const store = levelup(db, options)
store.open((err) => {
if (err) {
return reject(err)
}
// More backwards compatibility
if (db.status === 'unknown-shim') db.status = 'open'
resolve(store)
})
const store = levelup(db, options)
store.open((err) => {
if (err) {
return reject(err)
}
// More backwards compatibility
if (db.status === 'unknown-shim') db.status = 'open'
resolve(store)
})

@@ -49,0 +54,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