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.8.1-fc61eed.0 to 0.9.1-de44df3.0

customDir/000003.log

5

conf/webpack.config.js

@@ -31,6 +31,3 @@ import path from 'path'

'node_modules'
],
alias: {
leveldown: 'level-js'
}
]
},

@@ -37,0 +34,0 @@ resolveLoader: {

/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
/*!
* The buffer module from node.js, for the browser.

@@ -20,3 +13,1 @@ *

/*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */

26

package.json
{
"name": "orbit-db-storage-adapter",
"version": "0.8.1-fc61eed.0",
"version": "0.9.1-de44df3.0",
"description": "OrbitDB adapter for any abstract-leveldown compliant storage",

@@ -42,23 +42,21 @@ "main": "./src/index.js",

"level": "^8.0.0",
"level-js": "^6.1.0",
"mkdirp": "^1.0.4"
"mkdirp": "^2.1.1"
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/plugin-syntax-object-rest-spread": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/runtime": "^7.4.5",
"@babel/core": "^7.20.12",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.20.11",
"@babel/plugin-transform-runtime": "^7.19.6",
"@babel/preset-env": "^7.20.2",
"@babel/runtime": "^7.20.7",
"assert": "^2.0.0",
"babel-loader": "^8.0.6",
"babel-loader": "^9.1.2",
"buffer": "^6.0.3",
"memdown": "^6.1.1",
"mocha": "^10.0.0",
"mocha": "^10.2.0",
"mocha-headless-chrome": "^4.0.0",
"process": "^0.11.10",
"standard": "^17.0.0",
"webpack": "^5.74.0",
"webpack-cli": "^5.0.0"
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
}
}

@@ -26,2 +26,5 @@ import { Level } from 'level'

this.storage = storage
// TODO: we can probably remove all of the below as they're related
// to the older versions of leveldb
this.preCreate = options.preCreate ? options.preCreate : () => {}

@@ -35,2 +38,4 @@

async createStore (directory = './orbitdb', options = {}) {
// TODO: we can probably remove the two lines below as they're
// related to older versions of leveldb
this.options.up = options

@@ -50,3 +55,3 @@ await this.preCreate(directory, this.options)

async destroy (store) {
if (!this.storage.destory) return
if (!this.storage || !this.storage.destroy) return

@@ -53,0 +58,0 @@ await this.storage.destory(store._db.location)

import assert from 'assert'
import Storage from '../src/index.js'
import implementations from './implementations/index.js'

@@ -56,61 +54,49 @@ const timeout = 2000

for (const implementation of await implementations()) {
describe(`Storage Adapters - ${implementation.key}`, function () {
this.timeout(timeout)
describe('Storage Adapters - LevelDB', function () {
this.timeout(timeout)
let storage, store
let storage, store
const location = implementation.fileName
const server = implementation.server
beforeEach(async () => {
storage = Storage()
})
beforeEach(async () => {
const storageType = implementation.module
storage = Storage(storageType)
if (server && server.start) await implementation.server.start({})
})
afterEach(async () => {
await store.close()
await storage.destroy(store)
})
afterEach(async () => {
await store.close()
await storage.destroy(store)
if (server && server.afterEach) await implementation.server.afterEach()
})
it('Creates a store in default ./orbitdb directory', async () => {
store = await storage.createStore()
assert.strictEqual(store.status, 'open')
assert.strictEqual(store.location, './orbitdb')
})
after(async () => {
if (server && server.stop) await implementation.server.stop()
})
it('Creates a store in a custom directory', async () => {
store = await storage.createStore('./customDir')
assert.strictEqual(store.status, 'open')
assert.strictEqual(store.location, './customDir')
})
it('Creates a store in default ./orbitdb directory', async () => {
store = await storage.createStore(location, implementation.defaultOptions || {})
assert.strictEqual(store.status, 'open')
assert.strictEqual(store.location, location || './orbitdb')
data.forEach(d => {
it(`puts and gets a ${d.key}`, async () => {
store = await storage.createStore()
await store.put(d.key, JSON.stringify(d.value))
const val = await store.get(d.key)
const decodedVal = JSON.parse(val.toString())
assert.deepStrictEqual(decodedVal, d.value)
assert.strictEqual(typeof decodedVal, d.type)
})
it('Creates a store in a custom directory', async () => {
store = await storage.createStore(location || './customDir')
assert.strictEqual(store.status, 'open')
assert.strictEqual(store.location, location || './customDir')
it('deletes properly', async () => {
store = await storage.createStore()
await store.put(d.key, JSON.stringify(d.value))
await store.del(d.key, JSON.stringify(d.value))
try {
await store.get(d.key)
} catch (e) {
assert.strictEqual(true, true)
}
})
data.forEach(d => {
it(`puts and gets a ${d.key}`, async () => {
store = await storage.createStore(location, implementation.defaultOptions || {})
await store.put(d.key, JSON.stringify(d.value))
const val = await store.get(d.key)
const decodedVal = JSON.parse(val.toString())
assert.deepStrictEqual(decodedVal, d.value)
assert.strictEqual(typeof decodedVal, d.type)
})
it('deletes properly', async () => {
store = await storage.createStore(location, implementation.defaultOptions || {})
await store.put(d.key, JSON.stringify(d.value))
await store.del(d.key, JSON.stringify(d.value))
try {
await store.get(d.key)
} catch (e) {
assert.strictEqual(true, true)
}
})
})
})
}
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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