This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d2c40ec
Showing
7 changed files
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"predef": [ ] | ||
, "bitwise": false | ||
, "camelcase": false | ||
, "curly": false | ||
, "eqeqeq": false | ||
, "forin": false | ||
, "immed": false | ||
, "latedef": false | ||
, "noarg": true | ||
, "noempty": true | ||
, "nonew": true | ||
, "plusplus": false | ||
, "quotmark": true | ||
, "regexp": false | ||
, "undef": true | ||
, "unused": true | ||
, "strict": false | ||
, "trailing": true | ||
, "maxlen": 120 | ||
, "asi": true | ||
, "boss": true | ||
, "debug": true | ||
, "eqnull": true | ||
, "esnext": true | ||
, "evil": true | ||
, "expr": true | ||
, "funcscope": false | ||
, "globalstrict": false | ||
, "iterator": false | ||
, "lastsemic": true | ||
, "laxbreak": true | ||
, "laxcomma": true | ||
, "loopfunc": true | ||
, "multistr": false | ||
, "onecase": false | ||
, "proto": false | ||
, "regexdash": false | ||
, "scripturl": true | ||
, "smarttabs": false | ||
, "shadow": false | ||
, "sub": true | ||
, "supernew": false | ||
, "validthis": true | ||
, "browser": true | ||
, "couch": false | ||
, "devel": false | ||
, "dojo": false | ||
, "mootools": false | ||
, "node": true | ||
, "nonstandard": true | ||
, "prototypejs": false | ||
, "rhino": false | ||
, "worker": true | ||
, "wsh": false | ||
, "nomen": false | ||
, "onevar": true | ||
, "passfail": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Copyright 2012, Rod Vagg (the "Original Author") | ||
All rights reserved. | ||
|
||
MIT +no-false-attribs License | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
Distributions of all or part of the Software intended to be used | ||
by the recipients as they would use the unmodified Software, | ||
containing modifications that substantially alter, remove, or | ||
disable functionality of the Software, outside of the documented | ||
configuration mechanisms provided by the Software, shall be | ||
modified such that the Original Author's bug reporting email | ||
addresses and urls are either replaced with the contact information | ||
of the parties responsible for the changes, or removed entirely. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
|
||
Except where noted, this license applies to any and all software | ||
programs and associated documentation files created by the | ||
Original Author, when distributed with the Software. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Level | ||
===== | ||
|
||
![LevelDB Logo](https://twimg0-a.akamaihd.net/profile_images/3360574989/92fc472928b444980408147e5e5db2fa_bigger.png) | ||
|
||
### Fast & simple storage - a Node.js-style LevelDB wrapper** | ||
|
||
[![NPM](https://nodei.co/npm/level.png?stars&downloads)](https://nodei.co/npm/level/) [![NPM](https://nodei.co/npm-dl/level.png)](https://nodei.co/npm/level/) | ||
|
||
|
||
This is a convenience package that bundles the current release of **[LevelUP](https://github.com/rvagg/node-levelup)** and **[LevelDOWN](https://github.com/rvagg/node-leveldown)** and exposes LevelUP on its export. | ||
|
||
Use this package to avoid having to explicitly install LevelDOWN when you just want plain old LevelDB from LevelUP. | ||
|
||
```js | ||
var level = require('level') | ||
|
||
// 1) Create our database, supply location and options. | ||
// This will create or open the underlying LevelDB store. | ||
var db = level('./mydb') | ||
|
||
// 2) put a key & value | ||
db.put('name', 'Level', function (err) { | ||
if (err) return console.log('Ooops!', err) // some kind of I/O error | ||
|
||
// 3) fetch by key | ||
db.get('name', function (err, value) { | ||
if (err) return console.log('Ooops!', err) // likely the key was not found | ||
|
||
// ta da! | ||
console.log('name=' + value) | ||
}) | ||
}) | ||
``` | ||
|
||
See **[LevelUP](https://github.com/rvagg/node-levelup)** and **[LevelDOWN](https://github.com/rvagg/node-leveldown)** for more details. | ||
|
||
<a name="contributing"></a> | ||
Contributing | ||
------------ | ||
|
||
Level is an **OPEN Open Source Project**. This means that: | ||
|
||
> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. | ||
See the [CONTRIBUTING.md](https://github.com/Level/level/blob/master/CONTRIBUTING.md) file for more details. | ||
|
||
### Contributors | ||
|
||
Level, including LevelUP & LevelDOWN, is only possible due to the excellent work of the following contributors: | ||
|
||
<table><tbody> | ||
<tr><th align="left">Rod Vagg</th><td><a href="https://github.com/rvagg">GitHub/rvagg</a></td><td><a href="http://twitter.com/rvagg">Twitter/@rvagg</a></td></tr> | ||
<tr><th align="left">John Chesley</th><td><a href="https://github.com/chesles/">GitHub/chesles</a></td><td><a href="http://twitter.com/chesles">Twitter/@chesles</a></td></tr> | ||
<tr><th align="left">Jake Verbaten</th><td><a href="https://github.com/raynos">GitHub/raynos</a></td><td><a href="http://twitter.com/raynos2">Twitter/@raynos2</a></td></tr> | ||
<tr><th align="left">Dominic Tarr</th><td><a href="https://github.com/dominictarr">GitHub/dominictarr</a></td><td><a href="http://twitter.com/dominictarr">Twitter/@dominictarr</a></td></tr> | ||
<tr><th align="left">Max Ogden</th><td><a href="https://github.com/maxogden">GitHub/maxogden</a></td><td><a href="http://twitter.com/maxogden">Twitter/@maxogden</a></td></tr> | ||
<tr><th align="left">Lars-Magnus Skog</th><td><a href="https://github.com/ralphtheninja">GitHub/ralphtheninja</a></td><td><a href="http://twitter.com/ralphtheninja">Twitter/@ralphtheninja</a></td></tr> | ||
<tr><th align="left">David Björklund</th><td><a href="https://github.com/kesla">GitHub/kesla</a></td><td><a href="http://twitter.com/david_bjorklund">Twitter/@david_bjorklund</a></td></tr> | ||
<tr><th align="left">Julian Gruber</th><td><a href="https://github.com/juliangruber">GitHub/juliangruber</a></td><td><a href="http://twitter.com/juliangruber">Twitter/@juliangruber</a></td></tr> | ||
<tr><th align="left">Paolo Fragomeni</th><td><a href="https://github.com/hij1nx">GitHub/hij1nx</a></td><td><a href="http://twitter.com/hij1nx">Twitter/@hij1nx</a></td></tr> | ||
<tr><th align="left">Anton Whalley</th><td><a href="https://github.com/No9">GitHub/No9</a></td><td><a href="https://twitter.com/antonwhalley">Twitter/@antonwhalley</a></td></tr> | ||
<tr><th align="left">Matteo Collina</th><td><a href="https://github.com/mcollina">GitHub/mcollina</a></td><td><a href="https://twitter.com/matteocollina">Twitter/@matteocollina</a></td></tr> | ||
<tr><th align="left">Pedro Teixeira</th><td><a href="https://github.com/pgte">GitHub/pgte</a></td><td><a href="https://twitter.com/pgte">Twitter/@pgte</a></td></tr> | ||
<tr><th align="left">James Halliday</th><td><a href="https://github.com/substack">GitHub/substack</a></td><td><a href="https://twitter.com/substack">Twitter/@substack</a></td></tr> | ||
</tbody></table> | ||
|
||
|
||
<a name="licence"></a> | ||
Licence & copyright | ||
------------------- | ||
|
||
Copyright (c) 2012-2013 Level contributors (listed above). | ||
|
||
Level is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const levelup = require('levelup') | ||
|
||
function packager (leveldown) { | ||
function Level (location, options, callback) { | ||
if (typeof options == 'function') | ||
callback = options | ||
if (typeof options != 'object') | ||
options = {} | ||
|
||
options.db = leveldown | ||
|
||
return levelup(location, options, callback) | ||
} | ||
|
||
'copy destroy repair'.split(' ').forEach(function (m) { | ||
Level[m] = levelup[m] | ||
}) | ||
|
||
return Level | ||
} | ||
|
||
module.exports = packager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name" : "level-packager" | ||
, "description" : "LevelUP package helper for distributing with a LevelDOWN-compatible back-end" | ||
, "version" : "0.17.0" | ||
, "contributors" : [ | ||
"Rod Vagg <r@va.gg> (https://github.com/rvagg)" | ||
, "John Chesley <john@chesl.es> (https://github.com/chesles/)" | ||
, "Jake Verbaten <raynos2@gmail.com> (https://github.com/raynos)" | ||
, "Dominic Tarr <dominic.tarr@gmail.com> (https://github.com/dominictarr)" | ||
, "Max Ogden <max@maxogden.com> (https://github.com/maxogden)" | ||
, "Lars-Magnus Skog <lars.magnus.skog@gmail.com> (https://github.com/ralphtheninja)" | ||
, "David Björklund <david.bjorklund@gmail.com> (https://github.com/kesla)" | ||
, "Julian Gruber <julian@juliangruber.com> (https://github.com/juliangruber)" | ||
, "Paolo Fragomeni <paolo@async.ly> (https://github.com/hij1nx)" | ||
, "Anton Whalley <anton.whalley@nearform.com> (https://github.com/No9)" | ||
, "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)" | ||
, "Pedro Teixeira <pedro.teixeira@gmail.com> (https://github.com/pgte)" | ||
, "James Halliday <mail@substack.net> (https://github.com/substack)" | ||
] | ||
, "repository" : { | ||
"type" : "git" | ||
, "url" : "https://github.com/Level/level-packager.git" | ||
} | ||
, "homepage" : "https://github.com/Level/level-packager" | ||
, "keywords": [ | ||
"leveldb" | ||
, "stream" | ||
, "database" | ||
, "db" | ||
, "store" | ||
, "storage" | ||
, "json" | ||
] | ||
, "main" : "level-packager.js" | ||
, "dependencies" : { | ||
"levelup" : "~0.17.0" | ||
} | ||
, "devDependencies" : { | ||
"tape" : "*" | ||
} | ||
, "license" : "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const test = require('tape') | ||
, fs = require('fs') | ||
, path = require('path') | ||
, os = require('os') | ||
|
||
var location = path.join(os.tmpdir(), 'level-test-' + process.pid + '.db') | ||
|
||
module.exports = function (level) { | ||
|
||
test('test db open and use, level(location, cb)', function (t) { | ||
level(location, function (err, db) { | ||
t.notOk(err, 'no error') | ||
db.put('test1', 'success', function (err) { | ||
t.notOk(err, 'no error') | ||
db.close(t.end.bind(t)) | ||
}) | ||
}) | ||
}) | ||
|
||
test('test db open and use, level(location, options, cb)', function (t) { | ||
level(location, { createIfMissing: false, errorIfExists: false }, function (err, db) { | ||
t.notOk(err, 'no error') | ||
db.put('test2', 'success', function (err) { | ||
t.notOk(err, 'no error') | ||
db.close(t.end.bind(t)) | ||
}) | ||
}) | ||
}) | ||
|
||
// should use existing options object | ||
test('test db open and use, level(location, options, cb) force error', function (t) { | ||
level(location, { errorIfExists: true }, function (err, db) { | ||
t.ok(err, 'got error opening existing db') | ||
t.notOk(db, 'no db') | ||
t.end() | ||
}) | ||
}) | ||
|
||
test('test db open and use, db=level(location)', function (t) { | ||
var db = level(location) | ||
db.put('test3', 'success', function (err) { | ||
t.notOk(err, 'no error') | ||
db.close(t.end.bind(t)) | ||
}) | ||
}) | ||
|
||
test('test db values', function (t) { | ||
var c = 0 | ||
, db = level(location) | ||
|
||
function read (err, value) { | ||
t.notOk(err, 'no error') | ||
t.equal(value, 'success') | ||
if (++c == 3) | ||
db.close(t.end.bind(t)) | ||
} | ||
|
||
db.get('test1', read) | ||
db.get('test2', read) | ||
db.get('test3', read) | ||
}) | ||
|
||
test('test repair', function (t) { | ||
t.plan(1) | ||
level.repair(location, function (err) { | ||
t.notOk(err, 'no error') | ||
}) | ||
}) | ||
|
||
test('test destroy', function (t) { | ||
t.plan(4) | ||
t.ok(fs.statSync(location).isDirectory(), 'sanity check, directory exists') | ||
t.ok(fs.existsSync(path.join(location, 'LOG')), 'sanity check, log exists') | ||
level.destroy(location, function (err) { | ||
t.notOk(err, 'no error') | ||
t.notOk(fs.existsSync(path.join(location, 'LOG')), 'db gone (mostly)') | ||
}) | ||
}) | ||
} |