Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .appveyor.yml

This file was deleted.

32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

29 changes: 0 additions & 29 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
javascript(['nodejs_versions': ['8.11.1','9.2.0','10.0.0']])
javascript()
15 changes: 0 additions & 15 deletions circle.yml

This file was deleted.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@
},
"homepage": "https://github.com/ipfs/js-datastore-level#readme",
"dependencies": {
"datastore-core": "~0.4.0",
"encoding-down": "^5.0.2",
"interface-datastore": "~0.4.1",
"datastore-core": "~0.5.0",
"encoding-down": "^5.0.4",
"interface-datastore": "~0.5.0",
"level-js": "github:timkuijsten/level.js#idbunwrapper",
"leveldown": "^3.0.2",
"levelup": "^2.0.2",
"pull-stream": "^3.6.1"
"pull-stream": "^3.6.9"
},
"devDependencies": {
"aegir": "^13.1.0",
"async": "^2.6.0",
"aegir": "^15.2.0",
"async": "^2.6.1",
"chai": "^4.1.2",
"cids": "~0.5.3",
"dirty-chai": "^2.0.1",
"flow-bin": "^0.58.0",
"flow-bin": "~0.81.0",
"memdown": "^1.4.1",
"rimraf": "^2.6.2"
},
Expand Down
28 changes: 23 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const levelup = require('levelup')
const asyncFilter = require('interface-datastore').utils.asyncFilter
const asyncSort = require('interface-datastore').utils.asyncSort
const Key = require('interface-datastore').Key
const Errors = require('interface-datastore').Errors
const encode = require('encoding-down')

/**
Expand Down Expand Up @@ -50,15 +51,30 @@ class LevelDatastore {
}

open (callback /* : Callback<void> */) /* : void */ {
this.db.open(callback)
this.db.open((err) => {
if (err) {
return callback(Errors.dbOpenFailedError(err))
}
callback()
})
}

put (key /* : Key */, value /* : Buffer */, callback /* : Callback<void> */) /* : void */ {
this.db.put(key.toString(), value, callback)
this.db.put(key.toString(), value, (err) => {
if (err) {
return callback(Errors.dbWriteFailedError(err))
}
callback()
})
}

get (key /* : Key */, callback /* : Callback<Buffer> */) /* : void */ {
this.db.get(key.toString(), callback)
this.db.get(key.toString(), (err, data) => {
if (err) {
return callback(Errors.notFoundError(err))
}
callback(null, data)
})
}

has (key /* : Key */, callback /* : Callback<bool> */) /* : void */ {
Expand All @@ -78,8 +94,10 @@ class LevelDatastore {

delete (key /* : Key */, callback /* : Callback<void> */) /* : void */ {
this.db.del(key.toString(), (err) => {
// Avoid level passing additional arguments to callback, we dont need them
callback(err)
if (err) {
return callback(Errors.dbDeleteFailedError(err))
}
callback()
})
}

Expand Down