A levelup wrapper interface to add/modify behavior of a levelup instance.
Extend a levelup instance in layers, like an onion.
Each layer you add can expose new functionality or modify functionality of inner layers, or you can bypass the layers by using the inner unmodified layers.
WARNING This is currently experimental, and primarily a proof-of-concept. There are no guarantees that this will be a best practice for working with levelup, or be adopted by any significant portion of the levelup ecosystem.
Pros: Simple & low impact.
Cons: I'm not exactly thrilled with the convention it requires wrapping modules to comply with.
Example: case-insensitive keys:
Create a wrapping layer:
// Requiredthistype = "upper"// Default false, if true it will prevent you from double-wrapping with this wrapper.thisunique = false// Requires an install method that takes the wrapped db and the parent it is wrappingparentputkeytoUpperCase value cbparentgetkeytoUpperCase cb// ... etc.
Wrap a levelup instance with your wrapping layer:
var level = require"level"var wrap = require"level-onion"var ldb = level"/tmp/db"var db = wrapdb// ldb remains intact and unmodified// db now has the wrapper installed