(nut, prefix, createStream, options)
| 4176 | var NOT_FOUND_ERROR = new NotFoundError(); |
| 4177 | |
| 4178 | var sublevel = function (nut, prefix, createStream, options) { |
| 4179 | var emitter = new EventEmitter(); |
| 4180 | emitter.sublevels = {}; |
| 4181 | emitter.options = options; |
| 4182 | |
| 4183 | emitter.version = version$1; |
| 4184 | |
| 4185 | emitter.methods = {}; |
| 4186 | prefix = prefix || []; |
| 4187 | |
| 4188 | function mergeOpts(opts) { |
| 4189 | var o = {}; |
| 4190 | var k; |
| 4191 | if (options) { |
| 4192 | for (k in options) { |
| 4193 | if (typeof options[k] !== 'undefined') { |
| 4194 | o[k] = options[k]; |
| 4195 | } |
| 4196 | } |
| 4197 | } |
| 4198 | if (opts) { |
| 4199 | for (k in opts) { |
| 4200 | if (typeof opts[k] !== 'undefined') { |
| 4201 | o[k] = opts[k]; |
| 4202 | } |
| 4203 | } |
| 4204 | } |
| 4205 | return o; |
| 4206 | } |
| 4207 | |
| 4208 | emitter.put = function (key, value, opts, cb) { |
| 4209 | if ('function' === typeof opts) { |
| 4210 | cb = opts; |
| 4211 | opts = {}; |
| 4212 | } |
| 4213 | |
| 4214 | nut.apply([{ |
| 4215 | key, value, |
| 4216 | prefix: prefix.slice(), type: 'put' |
| 4217 | }], mergeOpts(opts), function (err) { |
| 4218 | /* istanbul ignore next */ |
| 4219 | if (err) { |
| 4220 | return cb(err); |
| 4221 | } |
| 4222 | emitter.emit('put', key, value); |
| 4223 | cb(null); |
| 4224 | }); |
| 4225 | }; |
| 4226 | |
| 4227 | emitter.prefix = function () { |
| 4228 | return prefix.slice(); |
| 4229 | }; |
| 4230 | |
| 4231 | emitter.batch = function (ops, opts, cb) { |
| 4232 | if ('function' === typeof opts) { |
| 4233 | cb = opts; |
| 4234 | opts = {}; |
| 4235 | } |
no test coverage detected
searching dependent graphs…