Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handler(err, v) {
// sanitize full keypath for notFound errors
if (err && err.notFound || NOT_FOUND.test(err)) {
try {
err = new NotFoundError('Key not found in database [' + k + ']')
}
catch (_) {}
}
cb(err, v)
}
}
var extend = require('xtend')
var prr = require('prr')
var DeferredLevelDOWN = require('deferred-leveldown')
var IteratorStream = require('level-iterator-stream')
var Batch = require('./batch')
var Codec = require('level-codec')
var getLevelDOWN = require('./leveldown')
var errors = require('level-errors')
var util = require('./util')
var WriteError = errors.WriteError
var ReadError = errors.ReadError
var NotFoundError = errors.NotFoundError
var OpenError = errors.OpenError
var EncodingError = errors.EncodingError
var InitializationError = errors.InitializationError
var LevelUPError = errors.LevelUPError
var getOptions = util.getOptions
var defaultOptions = util.defaultOptions
var dispatchError = util.dispatchError
function getCallback (options, callback) {
return typeof options === 'function' ? options : callback
}
// Possible LevelUP#_status values:
// - 'new' - newly created, not opened or closed
// - 'opening' - waiting for the database to be opened, post open()
// - 'open' - successfully opened the database, available for use
// - 'closing' - waiting for the database to be closed, post close()
// - 'closed' - database has been successfully closed, should not be
var inherits = require('util').inherits
var deprecate = require('util').deprecate
var extend = require('xtend')
var prr = require('prr')
var DeferredLevelDOWN = require('deferred-leveldown')
var IteratorStream = require('level-iterator-stream')
var Batch = require('./batch')
var Codec = require('level-codec')
var getLevelDOWN = require('./leveldown')
var errors = require('level-errors')
var util = require('./util')
var WriteError = errors.WriteError
var ReadError = errors.ReadError
var NotFoundError = errors.NotFoundError
var OpenError = errors.OpenError
var EncodingError = errors.EncodingError
var InitializationError = errors.InitializationError
var LevelUPError = errors.LevelUPError
var getOptions = util.getOptions
var defaultOptions = util.defaultOptions
var dispatchError = util.dispatchError
function getCallback (options, callback) {
return typeof options === 'function' ? options : callback
}
// Possible LevelUP#_status values:
// - 'new' - newly created, not opened or closed
// - 'opening' - waiting for the database to be opened, post open()
// - 'open' - successfully opened the database, available for use
var EventEmitter = require('events').EventEmitter
var inherits = require('util').inherits
var deprecate = require('util').deprecate
var extend = require('xtend')
var prr = require('prr')
var DeferredLevelDOWN = require('deferred-leveldown')
var IteratorStream = require('level-iterator-stream')
var Batch = require('./batch')
var Codec = require('level-codec')
var getLevelDOWN = require('./leveldown')
var errors = require('level-errors')
var util = require('./util')
var WriteError = errors.WriteError
var ReadError = errors.ReadError
var NotFoundError = errors.NotFoundError
var OpenError = errors.OpenError
var EncodingError = errors.EncodingError
var InitializationError = errors.InitializationError
var LevelUPError = errors.LevelUPError
var getOptions = util.getOptions
var defaultOptions = util.defaultOptions
var dispatchError = util.dispatchError
function getCallback (options, callback) {
return typeof options === 'function' ? options : callback
}
// Possible LevelUP#_status values:
// - 'new' - newly created, not opened or closed
var notFound = function (key) {
return new errors.NotFoundError('Key not found in database [' + key + ']')
}
return db.byRootHash(rootHash, function (err, entries) {
if (err) return cb(err)
var found = entries.some(function (e) {
if (e[CUR_HASH] === curHash) {
cb(null, e)
}
})
if (!found) {
cb(null, new levelErrs.NotFoundError())
}
})
})
put(val, function(err, d){
if(err){
callback(err);
}else if(d.is_new){
callback(new NotFoundError("No hash exists for that value"));
}else{
callback(null, d.hash);
}
});
},
}), function (err, entries) {
if (err) return cb(err)
if (!entries || !entries.length) {
return cb(new levelErrs.NotFoundError())
}
return cb(null, entries)
})
})
search(prop, value, function (err, results) {
if (!err && !results.length) {
err = new levelErrors.NotFoundError()
}
cb(err, results[0])
})
}
nut.get(key, prefix, mergeOpts(opts), function (err, value) {
if(err) cb(new errors.NotFoundError('Key not found in database', err))
else cb(null, value)
})
}