datastore-level
Advanced tools
Comparing version 0.12.0 to 0.12.1
@@ -0,1 +1,11 @@ | ||
<a name="0.12.1"></a> | ||
## [0.12.1](https://github.com/ipfs/js-datastore-level/compare/v0.12.0...v0.12.1) (2019-06-26) | ||
### Bug Fixes | ||
* swap leveldown/level.js for level ([#20](https://github.com/ipfs/js-datastore-level/issues/20)) ([d16e212](https://github.com/ipfs/js-datastore-level/commit/d16e212)) | ||
<a name="0.12.0"></a> | ||
@@ -2,0 +12,0 @@ # [0.12.0](https://github.com/ipfs/js-datastore-level/compare/v0.11.0...v0.12.0) (2019-05-29) |
{ | ||
"name": "datastore-level", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"description": "Datastore implementation with level(up|down) backend", | ||
"leadMaintainer": "Pedro Teixeira <pedro@protocol.ai>", | ||
"main": "src/index.js", | ||
"browser": { | ||
"leveldown": "level-js" | ||
}, | ||
"scripts": { | ||
@@ -44,7 +41,4 @@ "test": "aegir test", | ||
"datastore-core": "~0.7.0", | ||
"encoding-down": "^6.0.2", | ||
"interface-datastore": "~0.7.0", | ||
"level-js": "^4.0.1", | ||
"leveldown": "^5.0.0", | ||
"levelup": "^4.0.1" | ||
"level": "^5.0.1" | ||
}, | ||
@@ -56,3 +50,3 @@ "devDependencies": { | ||
"dirty-chai": "^2.0.1", | ||
"memdown": "^4.0.0", | ||
"level-mem": "^4.0.0", | ||
"rimraf": "^2.6.2" | ||
@@ -62,2 +56,3 @@ }, | ||
"Alan Shaw <alan.shaw@protocol.ai>", | ||
"Alex Potsides <alex@achingbrain.net>", | ||
"David Dias <daviddias.p@gmail.com>", | ||
@@ -71,5 +66,4 @@ "Friedel Ziegelmayer <dignifiedquire@gmail.com>", | ||
"Vasco Santos <vasco.santos@moxy.studio>", | ||
"Victor Bjelkholm <victorbjelkholm@gmail.com>", | ||
"achingbrain <alex@achingbrain.net>" | ||
"Victor Bjelkholm <victorbjelkholm@gmail.com>" | ||
] | ||
} |
@@ -24,10 +24,10 @@ # js-datastore-level | ||
- [js-datastore-level](#js-datastore-level) | ||
- [Lead Maintainer](#lead-maintainer) | ||
- [Table of Contents](#table-of-contents) | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Browser Shimming Leveldown](#browser-shimming-leveldown) | ||
- [Database names](#database-names) | ||
- [Contribute](#contribute) | ||
- [License](#license) | ||
- [Lead Maintainer](#Lead-Maintainer) | ||
- [Table of Contents](#Table-of-Contents) | ||
- [Install](#Install) | ||
- [Usage](#Usage) | ||
- [Browser Shimming Leveldown](#Browser-Shimming-Leveldown) | ||
- [Database names](#Database-names) | ||
- [Contribute](#Contribute) | ||
- [License](#License) | ||
@@ -45,15 +45,17 @@ ## Install | ||
// Default using leveldown as backend | ||
// Default using level as backend for node or the browser | ||
const store = new LevelStore('path/to/store') | ||
// use in the browser with level.js | ||
const browserStore = new LevelStore('my/db/name', {db: require('level-js')}) | ||
// another leveldown compliant backend like memdown | ||
const memStore = new LevelStore('my/mem/store', {db: require('memdown')}) | ||
const memStore = new LevelStore('my/mem/store', { | ||
db: require('level-mem') | ||
}) | ||
``` | ||
### Browser Shimming Leveldown | ||
As `leveldown` does not work in the browser, `LevelStore` takes advantage of the browser property in package.json to shim `level-js` in its place. Most modern bundlers such as webpack, will see the shim and replace it for use in the browser. If you are using a bundler that does not support pkg.browser, you will need to handle the shimming yourself, as was the case with versions of `LevelStore` 0.7.0 and earlier. | ||
`LevelStore` uses the `level` module to automatically use `level.js` if a modern bundler is used which can detect bundle targets based on the `pkg.browser` property in your `package.json`. | ||
If you are using a bundler that does not support `pkg.browser`, you will need to handle the shimming yourself, as was the case with versions of `LevelStore` 0.7.0 and earlier. | ||
### Database names | ||
@@ -60,0 +62,0 @@ |
'use strict' | ||
const levelup = require('levelup') | ||
const { Key, Errors, utils } = require('interface-datastore') | ||
const encode = require('encoding-down') | ||
const { filter, map, take, sortAll } = utils | ||
@@ -20,18 +17,10 @@ | ||
} else { | ||
// Default to leveldown db | ||
database = require('leveldown') | ||
database = require('level') | ||
} | ||
this.db = levelup( | ||
encode(database(path), { valueEncoding: 'binary' }), | ||
Object.assign({}, opts, { | ||
compression: false // same default as go | ||
}), | ||
(err) => { | ||
// Prevent an uncaught exception error on duplicate locks | ||
if (err) { | ||
throw err | ||
} | ||
} | ||
) | ||
this.db = database(path, { | ||
...opts, | ||
valueEncoding: 'binary', | ||
compression: false // same default as go | ||
}) | ||
} | ||
@@ -38,0 +27,0 @@ |
@@ -6,6 +6,3 @@ /* eslint-env mocha */ | ||
const { Key } = require('interface-datastore') | ||
// leveldown will be swapped for level-js | ||
const leveljs = require('leveldown') | ||
const leveljs = require('level') | ||
const LevelStore = require('../src') | ||
@@ -12,0 +9,0 @@ |
@@ -7,4 +7,4 @@ /* eslint-env mocha */ | ||
const expect = chai.expect | ||
const memdown = require('memdown') | ||
const LevelDown = require('leveldown') | ||
const levelmem = require('level-mem') | ||
const level = require('level') | ||
const os = require('os') | ||
@@ -19,3 +19,2 @@ const LevelStore = require('../src') | ||
expect(levelStore.db.db.db instanceof LevelDown).to.equal(true) | ||
expect(levelStore.db.options).to.include({ | ||
@@ -32,3 +31,3 @@ createIfMissing: true, | ||
const levelStore = new LevelStore('init-default', { | ||
db: memdown, | ||
db: levelmem, | ||
createIfMissing: true, | ||
@@ -40,3 +39,2 @@ errorIfExists: true | ||
expect(levelStore.db.db.db instanceof memdown).to.equal(true) | ||
expect(levelStore.db.options).to.include({ | ||
@@ -49,3 +47,3 @@ createIfMissing: true, | ||
;[memdown, LevelDown].forEach(database => { | ||
;[levelmem, level].forEach(database => { | ||
describe(`interface-datastore ${database.name}`, () => { | ||
@@ -52,0 +50,0 @@ require('interface-datastore/src/tests')({ |
@@ -20,3 +20,3 @@ /* eslint-env mocha */ | ||
require('interface-datastore/src/tests')({ | ||
setup: () => new LevelStore(dir, { db: require('leveldown') }), | ||
setup: () => new LevelStore(dir, { db: require('level') }), | ||
teardown: () => promisify(rimraf)(dir) | ||
@@ -38,3 +38,3 @@ }) | ||
datastore: new LevelStore(dirs[0], { | ||
db: require('leveldown') | ||
db: require('level') | ||
}) | ||
@@ -44,3 +44,3 @@ }, { | ||
datastore: new LevelStore(dirs[1], { | ||
db: require('leveldown') | ||
db: require('level') | ||
}) | ||
@@ -50,3 +50,3 @@ }, { | ||
datastore: new LevelStore(dirs[2], { | ||
db: require('leveldown') | ||
db: require('level') | ||
}) | ||
@@ -63,3 +63,3 @@ }]) | ||
const store = new LevelStore(path.join(__dirname, 'test-repo', 'datastore'), { | ||
db: require('leveldown') | ||
db: require('level') | ||
}) | ||
@@ -66,0 +66,0 @@ |
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
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
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
3
84
0
97029
295
+ Addedlevel@^5.0.1
+ Addedlevel@5.0.1(transitive)
+ Addedlevel-packager@5.1.1(transitive)
+ Addedopencollective-postinstall@2.0.3(transitive)
- Removedencoding-down@^6.0.2
- Removedlevel-js@^4.0.1
- Removedleveldown@^5.0.0
- Removedlevelup@^4.0.1
- Removedimmediate@3.3.0(transitive)