orbit-db-storage-adapter
Advanced tools
Comparing version 0.8.1-fc61eed.0 to 0.9.1-de44df3.0
@@ -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> */ |
{ | ||
"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
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
2
15
1
99918
32
515
+ Addedmkdirp@2.1.6(transitive)
- Removedlevel-js@^6.1.0
- Removedabstract-leveldown@7.2.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedlevel-concat-iterator@3.1.0(transitive)
- Removedlevel-js@6.1.0(transitive)
- Removedlevel-supports@2.1.0(transitive)
- Removedltgt@2.2.1(transitive)
- Removedmkdirp@1.0.4(transitive)
Updatedmkdirp@^2.1.1