Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

level-packager

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-packager - npm Package Compare versions

Comparing version 0.17.0 to 0.18.0

10

level-packager.js

@@ -15,4 +15,8 @@ const levelup = require('levelup')

'copy destroy repair'.split(' ').forEach(function (m) {
Level[m] = levelup[m]
[ 'destroy', 'repair' ].forEach(function (m) {
if (typeof leveldown[m] == 'function') {
Level[m] = function (location, callback) {
leveldown[m](location, callback || function () {})
}
}
})

@@ -23,2 +27,2 @@

module.exports = packager
module.exports = packager
{
"name" : "level-packager"
, "description" : "LevelUP package helper for distributing with a LevelDOWN-compatible back-end"
, "version" : "0.17.0"
, "version" : "0.18.0"
, "contributors" : [

@@ -36,8 +36,5 @@ "Rod Vagg <r@va.gg> (https://github.com/rvagg)"

, "dependencies" : {
"levelup" : "~0.17.0"
"levelup" : "~0.18.0"
}
, "devDependencies" : {
"tape" : "*"
}
, "license" : "MIT"
}

@@ -1,38 +0,14 @@

Level
=====
level-packager
==============
![LevelDB Logo](https://twimg0-a.akamaihd.net/profile_images/3360574989/92fc472928b444980408147e5e5db2fa_bigger.png)
### Fast & simple storage - a Node.js-style LevelDB wrapper**
**LevelUP package helper for distributing with a LevelDOWN-compatible back-end**
[![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/)
[![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-lmdb)** as example use-cases.
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.
Also available is a *test.js* file that can be used to verify that the user-package works as expected.
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>

@@ -42,3 +18,3 @@ Contributing

Level is an **OPEN Open Source Project**. This means that:
**level-packager** is an **OPEN Open Source Project**. This means that:

@@ -51,3 +27,3 @@ > 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.

Level, including LevelUP & LevelDOWN, is only possible due to the excellent work of the following contributors:
**level-packager**, including LevelUP & LevelDOWN, is only possible due to the excellent work of the following contributors:

@@ -75,4 +51,4 @@ <table><tbody>

Copyright (c) 2012-2013 Level contributors (listed above).
Copyright (c) 2012-2013 **level-packager** 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.
**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.

@@ -1,9 +0,8 @@

const test = require('tape')
, fs = require('fs')
const fs = require('fs')
, path = require('path')
, os = require('os')
var location = path.join(os.tmpdir(), 'level-test-' + process.pid + '.db')
var location = path.join(__dirname, 'level-test-' + process.pid + '.db')
module.exports = function (level) {
module.exports = function (test, level, options) {
options = options || {}

@@ -30,10 +29,12 @@ test('test db open and use, level(location, cb)', function (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()
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()
})
})
})
}

@@ -51,2 +52,11 @@ test('test db open and use, db=level(location)', function (t) {

, 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() }

@@ -60,23 +70,30 @@ function read (err, value) {

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) {
setup(function (err) {
t.notOk(err, 'no error')
db.get('test1', read)
db.get('test2', read)
db.get('test3', read)
})
})
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)')
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)')
})
})
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc