[Pkg-javascript-commits] [node-level-packager] 01/02: Imported Upstream version 0.18.0
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Mon Jun 30 19:38:59 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to branch master
in repository node-level-packager.
commit 21bfe5e832cc3ce71ccd96a02aa384c286264e5d
Author: Andrew Kelley <superjoe30 at gmail.com>
Date: Mon Jun 30 19:30:06 2014 +0000
Imported Upstream version 0.18.0
---
.gitignore | 1 +
.jshintrc | 59 ++++++++++++++++++++++++++++++++++
LICENSE | 39 ++++++++++++++++++++++
README.md | 51 +++++++++++++++++++++++++++++
level-packager.js | 26 +++++++++++++++
package.json | 39 ++++++++++++++++++++++
test.js | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 311 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b512c09
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..7937650
--- /dev/null
+++ b/.jshintrc
@@ -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
+}
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..76d07a0
--- /dev/null
+++ b/LICENSE
@@ -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.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..525406f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,51 @@
+level-packager
+==============
+
+![LevelDB Logo](https://twimg0-a.akamaihd.net/profile_images/3360574989/92fc472928b444980408147e5e5db2fa_bigger.png)
+
+**LevelUP package helper for distributing with a LevelDOWN-compatible back-end**
+
+[![NPM](https://nodei.co/npm/level-packager.png?stars&downloads)](https://nodei.co/npm/level-packager/) [![NPM](https://nodei.co/npm-dl/level-packager.png)](https://nodei.co/npm/level-packager/)
+
+**level-packager** exports single function which takes a single argument, a LevelDOWN-API compatible storage back-end for LevelUP. The function returns a constructor function that will bundle LevelUP with the given LevelDOWN replacement. The full API is supported, including all optional arguments, `repair()`, `delete()` and `copy()`. See **[level](https://github.com/Level/level)**, **[level-hyper](https://github.com/Level/level-hyper)** or **[level-lmdb](https://github.com/Level/level-lm [...]
+
+Also available is a *test.js* file that can be used to verify that the user-package works as expected.
+
+<a name="contributing"></a>
+Contributing
+------------
+
+**level-packager** 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-packager**, 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-packager** contributors (listed above).
+
+**level-packager** 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.
diff --git a/level-packager.js b/level-packager.js
new file mode 100644
index 0000000..b11195e
--- /dev/null
+++ b/level-packager.js
@@ -0,0 +1,26 @@
+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)
+ }
+
+ [ 'destroy', 'repair' ].forEach(function (m) {
+ if (typeof leveldown[m] == 'function') {
+ Level[m] = function (location, callback) {
+ leveldown[m](location, callback || function () {})
+ }
+ }
+ })
+
+ return Level
+}
+
+module.exports = packager
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..070d1e0
--- /dev/null
+++ b/package.json
@@ -0,0 +1,39 @@
+{
+ "name" : "level-packager"
+ , "description" : "LevelUP package helper for distributing with a LevelDOWN-compatible back-end"
+ , "version" : "0.18.0"
+ , "contributors" : [
+ "Rod Vagg <r at va.gg> (https://github.com/rvagg)"
+ , "John Chesley <john at chesl.es> (https://github.com/chesles/)"
+ , "Jake Verbaten <raynos2 at gmail.com> (https://github.com/raynos)"
+ , "Dominic Tarr <dominic.tarr at gmail.com> (https://github.com/dominictarr)"
+ , "Max Ogden <max at maxogden.com> (https://github.com/maxogden)"
+ , "Lars-Magnus Skog <lars.magnus.skog at gmail.com> (https://github.com/ralphtheninja)"
+ , "David Björklund <david.bjorklund at gmail.com> (https://github.com/kesla)"
+ , "Julian Gruber <julian at juliangruber.com> (https://github.com/juliangruber)"
+ , "Paolo Fragomeni <paolo at async.ly> (https://github.com/hij1nx)"
+ , "Anton Whalley <anton.whalley at nearform.com> (https://github.com/No9)"
+ , "Matteo Collina <matteo.collina at gmail.com> (https://github.com/mcollina)"
+ , "Pedro Teixeira <pedro.teixeira at gmail.com> (https://github.com/pgte)"
+ , "James Halliday <mail at 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.18.0"
+ }
+ , "license" : "MIT"
+}
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..426cad7
--- /dev/null
+++ b/test.js
@@ -0,0 +1,96 @@
+const fs = require('fs')
+ , path = require('path')
+
+var location = path.join(__dirname, 'level-test-' + process.pid + '.db')
+
+module.exports = function (test, level, options) {
+ options = options || {}
+
+ 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))
+ })
+ })
+ })
+
+ if (!options.skipErrorIfExistsTest) {
+ // 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)
+ , setup = options.nonPersistent
+ ? function (callback) {
+ db.batch([
+ { type: 'put', key: 'test1', value: 'success' }
+ , { type: 'put', key: 'test2', value: 'success' }
+ , { type: 'put', key: 'test3', value: 'success' }
+ ], callback)
+ }
+ : function (callback) { callback() }
+
+ function read (err, value) {
+ t.notOk(err, 'no error')
+ t.equal(value, 'success')
+ if (++c == 3)
+ db.close(t.end.bind(t))
+ }
+
+ setup(function (err) {
+ t.notOk(err, 'no error')
+ db.get('test1', read)
+ db.get('test2', read)
+ db.get('test3', read)
+ })
+ })
+
+ if (!options.skipRepairTest) {
+ test('test repair', function (t) {
+ t.plan(1)
+ level.repair(location, function (err) {
+ t.notOk(err, 'no error')
+ })
+ })
+ }
+
+ if (!options.skipDestroyTest) {
+ 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)')
+ })
+ })
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-level-packager.git
More information about the Pkg-javascript-commits
mailing list