abstract-stream-leveldown
v1.1.1
Published
A stream-based abstract prototype matching the LevelDOWN API
Downloads
11
Readme
abstract-stream-leveldown
This library provides a smaller API footprint for using AbstractLevelDOWN to create a LevelDOWN backend, by implementing a Readable and Writable stream instead of all of the abstract LevelDOWN methods. It's a good fit for turning something that already has readable and writable stream interfaces into a LevelDOWN backend.
Example
in es6
import {AbstractStreamLevelDOWN} from "abstract-stream-leveldown"
class MyLevelDOWN extends AbstractStreamLevelDOWN {
_createReadStream([options]) { /* return a Readable */ }
_createWriteStream([options]) { /* return a Writable */ }
}
in es5
var inherits = require('inherits')
var assign = require('object-assign')
var AbstractStreamLevelDOWN = require('abstract-stream-leveldown').AbstractStreamLevelDOWN
function MyLevelDOWN (location) {
AbstractLevelDOWN.call(this, location)
}
inherits(MyLevelDOWN, AbstractStreamLevelDOWN)
assign(AbstractStreamLevelDOWN, {
_createReadStream([options]) { /* return a Readable */ }
_createWriteStream([options]) { /* return a Writable */ }
}
API
AbstractStreamLevelDOWN#_createReadStream([options])
Returns a Readable stream. options
should support the same properties as those to be passed to createReadStream.
AbstractStreamLevelDOWN#_createWriteStream([options])
Returns a Writable stream. options
should support the same properties as those to be passed to put. This stream accepts {key, value}
objects, and will perform a del
if the value is null or undefined, and a put
otherwise.