├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── example.js ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | tmp/ 4 | npm-debug.log* 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | node_js: 2 | - "0.12" 3 | - "4" 4 | sudo: false 5 | language: node_js 6 | script: "npm run test:cov" 7 | after_script: "npm i -g codecov.io && cat ./coverage/lcov.info | codecov" 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yoshua Wuyts 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # named-level-store [![stability][0]][1] 2 | [![npm version][2]][3] [![build status][4]][5] [![test coverage][6]][7] 3 | [![downloads][8]][9] [![js-standard-style][10]][11] 4 | 5 | Create a levelDB instance on your local machine. Will return the same database 6 | given the same name, each time 7 | 8 | ## Usage 9 | ```js 10 | const level = require('named-level-store') 11 | const db = level('my-cool-database-name') 12 | console.log(db.location) 13 | // => /Users/anon/.leveldb/my-cool-database-name 14 | ``` 15 | 16 | ## API 17 | ### db = level(name) 18 | Create a database under `~/.leveldb`. Useful to create a database and not have 19 | to worry where it's stored. Sets the `db.location` property to reflect where 20 | the database was stored 21 | 22 | ## Installation 23 | ```sh 24 | $ npm install named-level-store 25 | ``` 26 | 27 | ## License 28 | [MIT](https://tldrlegal.com/license/mit-license) 29 | 30 | [0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square 31 | [1]: https://nodejs.org/api/documentation.html#documentation_stability_index 32 | [2]: https://img.shields.io/npm/v/named-level-store.svg?style=flat-square 33 | [3]: https://npmjs.org/package/named-level-store 34 | [4]: https://img.shields.io/travis/yoshuawuyts/named-level-store/master.svg?style=flat-square 35 | [5]: https://travis-ci.org/yoshuawuyts/named-level-store 36 | [6]: https://img.shields.io/codecov/c/github/yoshuawuyts/named-level-store/master.svg?style=flat-square 37 | [7]: https://codecov.io/github/yoshuawuyts/named-level-store 38 | [8]: http://img.shields.io/npm/dm/named-level-store.svg?style=flat-square 39 | [9]: https://npmjs.org/package/named-level-store 40 | [10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square 41 | [11]: https://github.com/feross/standard 42 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | const level = require('./') 2 | const db = level('my-cool-database-name') 3 | console.log(db.location) 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | const mkdirp = require('mkdirp') 3 | const level = require('level') 4 | const path = require('path') 5 | 6 | module.exports = namedLevelStore 7 | 8 | // Create a levelDB instance on your local machine 9 | // str -> obj 10 | function namedLevelStore (name) { 11 | assert.equal(typeof name, 'string', 'named-level-store: name should be a string') 12 | const location = path.join(process.env.HOME, '.leveldb', name) 13 | mkdirp.sync(location) 14 | const db = level(location) 15 | db.location = location 16 | return db 17 | } 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "named-level-store", 3 | "version": "1.0.0", 4 | "description": "Create a levelDB instance on your local machine", 5 | "main": "index.js", 6 | "scripts": { 7 | "deps": "dependency-check . && dependency-check . --extra --no-dev", 8 | "test": "standard && npm run deps", 9 | "test:cov": "standard && npm run deps" 10 | }, 11 | "repository": "yoshuawuyts/named-level-store", 12 | "keywords": [ 13 | "leveldb", 14 | "local", 15 | "create" 16 | ], 17 | "license": "MIT", 18 | "dependencies": { 19 | "level": "^1.5.0", 20 | "mkdirp": "^0.5.1" 21 | }, 22 | "devDependencies": { 23 | "dependency-check": "^2.6.0", 24 | "istanbul": "^0.4.5", 25 | "standard": "^8.5.0", 26 | "tape": "^4.6.2" 27 | } 28 | } 29 | --------------------------------------------------------------------------------