You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
840 B
34 lines
840 B
/* Copyright (c) 2012-2016 LevelUP contributors |
|
* See list at <https://github.com/level/levelup#contributing> |
|
* MIT License |
|
* <https://github.com/level/levelup/blob/master/LICENSE.md> |
|
*/ |
|
|
|
var defaultOptions = { |
|
createIfMissing: true, |
|
errorIfExists: false, |
|
keyEncoding: 'utf8', |
|
valueEncoding: 'utf8', |
|
compression: true |
|
} |
|
|
|
function getOptions (options) { |
|
if (typeof options === 'string') { options = { valueEncoding: options } } |
|
if (typeof options !== 'object') { options = {} } |
|
return options |
|
} |
|
|
|
function dispatchError (db, error, callback) { |
|
typeof callback === 'function' ? callback(error) : db.emit('error', error) |
|
} |
|
|
|
function isDefined (v) { |
|
return typeof v !== 'undefined' |
|
} |
|
|
|
module.exports = { |
|
defaultOptions: defaultOptions, |
|
getOptions: getOptions, |
|
dispatchError: dispatchError, |
|
isDefined: isDefined |
|
}
|
|
|