Skip to content

Commit

Permalink
fix: pass backwards-compatible level-js options (#215)
Browse files Browse the repository at this point in the history
* fix: pass backwards-compatible level-js options

* fix: fix options test

* fix: configure datastore prefix and get right level version
  • Loading branch information
achingbrain authored and jacobheun committed Nov 29, 2019
1 parent 7e95e88 commit 6286167
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"cids": "~0.7.0",
"datastore-core": "~0.7.0",
"datastore-fs": "~0.9.0",
"datastore-level": "~0.12.0",
"datastore-level": "~0.14.0",
"debug": "^4.1.0",
"err-code": "^2.0.0",
"interface-datastore": "^0.8.0",
Expand Down
17 changes: 14 additions & 3 deletions src/default-options-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ module.exports = {
},
storageBackendOptions: {
root: {
extension: ''
extension: '',
prefix: '',
version: 2
},
blocks: {
sharding: false
sharding: false,
prefix: '',
version: 2
},
keys: {
sharding: false
sharding: false,
prefix: '',
version: 2
},
datastore: {
sharding: false,
prefix: '',
version: 2
}
}
}
29 changes: 3 additions & 26 deletions test/options-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,9 @@ describe('custom options tests', () => {
function noop () {}

function expectedRepoOptions () {
const options = {
lock: process.browser ? 'memory' : 'fs',
storageBackends: {
// packages are exchanged to browser-compatible
// equivalents via package.browser
root: require('datastore-fs'),
blocks: require('datastore-fs'),
keys: require('datastore-fs'),
datastore: require('datastore-level')
},
storageBackendOptions: {
root: {
extension: ''
},
keys: {},
blocks: {
sharding: true,
extension: '.data'
}
}
}

if (process.browser) {
options.storageBackendOptions.keys.sharding = false
delete options.storageBackendOptions.blocks.extension
options.storageBackendOptions.blocks.sharding = false
return require('../src/default-options-browser')
}
return options

return require('../src/default-options')
}

0 comments on commit 6286167

Please sign in to comment.