├── .gitignore ├── .travis.yml ├── History.md ├── Makefile ├── README.md ├── index.js ├── package.json └── test ├── memdb.js └── path.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.sw* 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | node_js: 4 | - "0.12" 5 | - 4 6 | - 6 7 | - 7 8 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 0.2.0 / 2014-04-28 3 | ================== 4 | 5 | * bump memdown, levelup 6 | * add make test 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | test: 3 | @node_modules/.bin/tape test/*.js 4 | 5 | .PHONY: test 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # MemDB 3 | 4 | [LevelUp](https://npmjs.org/package/levelup) + 5 | [MemDown](https://npmjs.org/package/memdown). Superseded by [level-mem](https://github.com/Level/mem). 6 | 7 | [![build status](https://secure.travis-ci.org/juliangruber/memdb.png)](http://travis-ci.org/juliangruber/memdb) 8 | 9 | [![testling badge](https://ci.testling.com/juliangruber/memdb.png)](https://ci.testling.com/juliangruber/memdb) 10 | 11 | ## Usage 12 | 13 | ```js 14 | var MemDB = require('memdb'); 15 | var db = MemDB(); 16 | ``` 17 | 18 | ## API 19 | 20 | ### MemDB([opts, ][fn]) 21 | 22 | Initialize the `db` with `opts` and either return a `db` or call `fn` with it. 23 | 24 | ### MemDB#{get,put,del,...} 25 | 26 | See [LevelUp](https://npmjs.org/package/levelup). 27 | 28 | ## Installation 29 | 30 | With [npm](https://npmjs.org) do: 31 | 32 | ```bash 33 | npm install memdb 34 | ``` 35 | 36 | Then bundle for the browser with 37 | [browserify](https://github.com/substack/node-browserify). 38 | 39 | ## License 40 | 41 | (MIT) 42 | 43 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 44 | 45 | Permission is hereby granted, free of charge, to any person obtaining a copy of 46 | this software and associated documentation files (the "Software"), to deal in 47 | the Software without restriction, including without limitation the rights to 48 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 49 | of the Software, and to permit persons to whom the Software is furnished to do 50 | so, subject to the following conditions: 51 | 52 | The above copyright notice and this permission notice shall be included in all 53 | copies or substantial portions of the Software. 54 | 55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 56 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 57 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 58 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 59 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 60 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 61 | SOFTWARE. 62 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var levelup = require('levelup'); 2 | var memdown = require('memdown'); 3 | 4 | module.exports = MemDB; 5 | 6 | function MemDB (opts, fn) { 7 | if (typeof opts == 'function') { 8 | fn = opts; 9 | opts = {}; 10 | } 11 | if (typeof opts == 'string') opts = {}; 12 | opts = opts || {}; 13 | opts.db = function (l) { return new memdown(l) }; 14 | return levelup('', opts, fn); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "memdb", 3 | "description": "LevelUp + MemDown", 4 | "version": "1.3.1", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/juliangruber/memdb.git" 8 | }, 9 | "homepage": "https://github.com/juliangruber/memdb", 10 | "main": "index.js", 11 | "scripts": { 12 | "test": "make test" 13 | }, 14 | "dependencies": { 15 | "memdown": "^1.0.0", 16 | "levelup": "^1.3.1" 17 | }, 18 | "devDependencies": { 19 | "tape": "^4.6.0" 20 | }, 21 | "keywords": [ 22 | "levelup", 23 | "memdown", 24 | "leveldb", 25 | "level" 26 | ], 27 | "author": { 28 | "name": "Julian Gruber", 29 | "email": "mail@juliangruber.com", 30 | "url": "http://juliangruber.com" 31 | }, 32 | "license": "MIT", 33 | "testling": { 34 | "files": "test/*.js", 35 | "browsers": [ 36 | "ie/8..latest", 37 | "firefox/17..latest", 38 | "firefox/nightly", 39 | "chrome/22..latest", 40 | "chrome/canary", 41 | "opera/12..latest", 42 | "opera/next", 43 | "safari/5.1..latest", 44 | "ipad/6.0..latest", 45 | "iphone/6.0..latest", 46 | "android-browser/4.2..latest" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/memdb.js: -------------------------------------------------------------------------------- 1 | var test = require('tape'); 2 | var MemDB = require('..'); 3 | 4 | test('MemDB', function (t) { 5 | t.plan(3); 6 | var db = MemDB(); 7 | db.put('foo', 'bar', function (err) { 8 | t.error(err); 9 | db.get('foo', function (err, value) { 10 | t.error(err); 11 | t.equal(value, 'bar'); 12 | }); 13 | }); 14 | }); 15 | 16 | test('no global state', function (t) { 17 | t.plan(3); 18 | 19 | var a = MemDB(); 20 | var b = MemDB(); 21 | 22 | a.put('foo', 'bar', function (err) { 23 | t.error(err); 24 | b.get('foo', function (err, val) { 25 | t.ok(err, 'had error') 26 | t.notEqual(val, 'bar') 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /test/path.js: -------------------------------------------------------------------------------- 1 | var test = require('tape'); 2 | var MemDB = require('..'); 3 | 4 | test('string path', function (t) { 5 | t.plan(1); 6 | var db = MemDB('ofoo'); 7 | t.ok(true); 8 | }); 9 | --------------------------------------------------------------------------------