abstract-leveldownstore for Node.js and browsers.
If you are upgrading: please see the upgrade guide.
const levelup =const memdown =const db =db
Your data is discarded when the process ends or you release a reference to the store. Note as well, though the internals of
memdown operate synchronously -
levelup does not.
memdown requires a ES5-capable browser. If you're using one that's isn't (e.g. PhantomJS, Android < 4.4, IE < 10) then you will need es5-shim.
memdown does not stringify keys or values. This means that in addition to Buffers, you can store any JS type without the need for
encoding-down. For keys for example, you could use Buffers or strings, which sort lexicographically, or numbers, even Dates, which sort naturally. The only exceptions are
undefined. Keys of that type are rejected; values of that type are converted to empty strings.
const db =db
If you desire normalization for keys and values (e.g. to stringify numbers), wrap
encoding-down. Alternatively install
level-mem which conveniently bundles
encoding-down. Such an approach is also recommended if you want to achieve universal (isomorphic) behavior. For example, you could have
leveldown in a backend and
memdown in the frontend.
const encode =const db =db
memdown store is backed by a fully persistent data structure and thus has snapshot guarantees. Meaning that reads operate on a snapshot in time, unaffected by simultaneous writes. Do note
memdown cannot uphold this guarantee for (copies of) object references. If you store object values, be mindful of mutating referenced objects:
const db =const obj = thing: 'original'db
memdown is wrapped with
encoding-down it stores representations rather than references.
const encode =const db =const obj = thing: 'original'db
In addition to the regular
npm test, you can test
memdown in a browser of choice with:
npm run test-browser-local
To check code coverage:
npm run coverage
memdown is Copyright (c) 2013-2017 Rod Vagg @rvagg and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.